Code for the file dependency in cache, DOT NET Programming

Assignment Help:

Show the code for the file dependency in cache?

Partial Class

Default_aspx

Public Sub displayAnnouncement() Dim announcement As String

If Cache("announcement") Is Nothing Then

Dim file As New _ System.IO.StreamReader _

(Server.MapPath("announcement.txt")) announcement = file.ReadToEnd file.Close()

Dim depends As New _ System.Web.Caching.CacheDependency _

(Server.MapPath("announcement.txt")) Cache.Insert("announcement", announcement, depends)

End If

Response.Write(CType(Cache("announcement"), String)) End Sub

Private Sub Page_Init(ByVal sender As Object, ByVal e As

System.EventArgs) Handles Me.Init displayAnnouncement()

The Above given process display Announcement () displays banner text from the Announcement.txt file that is lying in  the application path of the web directory. The Above method first checks whether the Cache object is nothing, if the cache object is nothing then it moves further to load the cache data from the file. When the file data changes the cache object is removed and set to nothing.


Related Discussions:- Code for the file dependency in cache

Explain custom authentication, Custom authentication: If we don't need ...

Custom authentication: If we don't need ASP.NET to perform any authentication, we can set the authentication mode to none. The reason behind this decision could be: We don't

Leasetime, What are LeaseTime, Sponsorship Time, Renew on Call Time and Lea...

What are LeaseTime, Sponsorship Time, Renew on Call Time and Lease Manager Poll Time? In the normal .NET environment objects lifetime is managed by garbage collector. But inrem

What is the difference between the take and skip clauses, What is the diffe...

What is the difference between the Take and Skip clauses? The Take clause returns a specified number of elements. For instance, you can use the Take clause to return two values

Load multiple tables in a data set, How can we load multiple tables in a Da...

How can we load multiple tables in a DataSet ? objCommand.CommandText = "Table1" objDataAdapter.Fill(objDataSet, "Table1") objCommand.CommandText = "Table2"

Difference between panel and group box classes, Difference between Panel an...

Difference between Panel and Group Box classes? Panel & Group box both can used as container for other controls like radio buttons & check box. the difference in panel & group

What is the difference between oledb provider and sqlclient, What is the di...

What is the difference between OLEDB Provider and SqlClient? With respect to usage, there is no difference among OLEDB Provider and SqlClient. The dissimilarity lies in their p

Need vb.net windows application programmer, We need vb.net windows applicat...

We need vb.net windows application programmer with min six years exp to work on our email marketing project Project Description: We need a windows application vb.net programm

Php project for narivramanarao for email, Php project for Narivramanarao Fo...

Php project for Narivramanarao For email Project Description: This is a project for Narivramanarao for emails and for php.rar please bid on the project and let's get started

Website programming , Question 1 A small Canadian law firm specializin...

Question 1 A small Canadian law firm specializing in immigration law has what it considers a successful website. One of the most popular features of the website is its newslet

What is an interface and abstract class, What is an interface and what is a...

What is an interface and what is an abstract class? Please, expand by examples of using both. Explain why.   In a interface class, all methods are abstract without execut

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd