Share via


ASP.NET Soup To Nuts: Caching

Well, Today is the day I all of you a little Cache. :-)  I'll be showing you how to use Page Output Caching, Partial Page Caching (aka Fragment Caching.)  I'll also show you how you can use caching internally to your own application with a cool kind of data caching.  Oh, you'll also learn how to actually configure caching via the web.config file.

Sign up here and watch, it'll be interesting.  Glen Gordon (my Teammate from Atlanta) will be joining me for a little Q&A.

<Follow Up> As promised, here is the demo code for that session. </Follow Up>

Bill

Comments

  • Anonymous
    March 14, 2006
    I'm a very late webcommer to the ASP2Nuts series. They are really cool!! I've just completed session 7, Adding Pizzazz to Your Web Site. If you recally that code had given you a hard time.

    Well I've hacked at it an have a solution I would be happy to upload if you want (and tell me how to go about it).

    In essence the problems with that code were the following:

    1. When you click the hyperlinks the Page.Request object no longer contains a value of Red / Blue. To persist the data, I opted for a session variable.
    2. Since you are using masterpages it seems the controls gets the extended name of "ctl00$ContentPlaceHolder1$Themes" tather than simply "Theme".

    Below is the solution. The PreInit section of each of the three pages contains the following code

       Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
           Dim strTheme As String

           ' Was theme set via the drop down list?
           strTheme = Page.Request("ctl00$ContentPlaceHolder1$Themes")

           ' If use the prvious setting if one exists (will always exist except first time Default.aspx is called)
           If (strTheme = "") Then
               strTheme = Session("Theme")
           End If

           ' First time default.aspx is called set the page to Red
           If (strTheme = "") Then
               strTheme = "Red"
           End If

           Page.Theme = strTheme

           ' Store the Page.Theme in the session valriable. This is necessary
           ' when hyperlinks are called since there is no Page.Request information
           Session("Theme") = Page.Theme
       End Sub

    I also did some other changes.

    I couldn't post under the original topic cause it seems to be locked.

    Regards,
    Al