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
What is the difference among a toolstrip drop-down button and a toolstrip split button? The difference among a toolstrip drop-down button and a toolstrip split button is that a

Project Description: Looking for a developer who will develop a web portal like zulutrade, some features will be taken from signaltrader The changes would be like: 1) Only

Require an expert Web Developer Our small business wants an experienced web developer to provide ongoing technical support for two websites. Experience with ASP.NET is a must.

How can you add or remove rows from the DataTable object of DataSet? The DataRowCollection class explains the collection of rows for the DataTable object in a DataSet. The Data

Explain the WSDL. WSDL is a short form for Web Services Description Language, which is used to explain a Web service in terms of the messages that it forms and accepts. The WS

Develop .Net project Project Description: We want to make .net you have to be good knowledge on the subsequent Microsoft Active Directory, Lync 2010 - 2013 databases

hello,i want to ask that i have to make a test taker just like a quiz in vb.net which should b like mcq''z one...it must contain a connectivity with database of oracle or MS access

What is a static constructor? Static constructors are introduced with C# to initialize the static data of a class. CLR calls the static constructor before the initial instance

Program of addition of byte type variables - C# Program Program of addition of byte type variables, i need program code for performing addition of byte type variables. Can any

Media Player App Development for Windows 8.1 platform with outstanding UI, flexible controls and simple to use. The app should be consist of 1. Normal player controls 2. s