Code for the file dependency in cache, DOT NET Programming

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.

Posted Date: 9/22/2012 2:13:20 AM | Location : United States







Related Discussions:- Code for the file dependency in cache, Assignment Help, Ask Question on Code for the file dependency in cache, Get Answer, Expert's Help, Code for the file dependency in cache Discussions

Write discussion on Code for the file dependency in cache
Your posts are moderated
Related Questions
Mention the name of the directory where it is essential to locate the proxy file to use a Web service. The proxy file must be kept in the /bin directory. This directory is situ

Project Description: I want a new payment gateway of my own. Anyone who has previous experience in preparing a new payment gateway. I mean new payment gateway not any integratio

Explain ExpandoObject and DynamicObject classes. The ExpandoObject class refers to a class whose members can be explicitly added and removed at runtime. In other words, the Exp

Project Description: We are seeking a simple tool that can convert an existing flash file (.SWF) into HTML5. Our idea is to convert small flash games into html5 games. Please NO


What does a break statement do in the switch statement? The switch statement is a selection control statement that is used to handle many choices and transfer control to the ca

Advertizing Project Description: I am preparing a MLM business. I can need direct mailing and coupon books as a product in my website. Skills required are .NET, C# Program

What are the benefits of using of ADO.NET in .NET 4.0. The following are the benefits of using ADO.NET in .NET 4.0 are as follows: Language-Integrated Query (LINQ) - Adds

How is anchoring different from docking? Docking refers to attaching a control to either an edge (top, right, bottom, or left) or the client area of the parent control. On the

In this task, you are required to create an Account Management application with Web Form. Your Account Management application must have the following pages: 1.  Create an accoun