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
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

Explain in brief DataAdapter class in ADO.NET. The DataAdapter class retrieves data from the database, keeps data in a dataset, and reflects the changes made in the dataset to

What is XML? Extensible markup language (XML) is all about describing the data. Below is a XML which describes an invoice data. Shoes   12 10

What is event bubbling? The Server controls such as  DataList, Datagrid,  Repeater can have another child controls inside them. For example the DataGrid can have combo box ins

how to connect login page with my database and check the values with the database.

I want high skilled C++ programmers Project Description: I want to hire the developer, who are proficient in C/C++ and have experience with STL and work with the data structu

The steps that occur when we request a ASPX page are as follows:- 1) The browser sends the request to the webserver. Now  assume that the webserver at the other end is IIS. 2

Which template must you provide, in order to display data in a Repeater control? ItemTemplate.To display data in the ItemTemplate, declare one or more Web server controls and s

What are events? As compared to the delegates events works with source and listener methodology. So the listeners who are interested in receiving few events they subscribe to t

What is DBMS? It is a collection of programs that enables user to make and maintain a database. In other words it is general-purpose software that gives the users with the proc