When I use the partialcaching attribute on my custom control (not a user
control) it really doesn't seem to do anything at all and I'm wondering what
the proper way to do ths is? Here is the code I'm trying. I don't have a
clue how to do this so any help would be great. The part enclosed in
asterisks is the first attemo. It didn't throw any exceptions but I would
always get " not cached" in the HTML source.
Thanks for any help,
Jason MacKenzie
<PartialCaching(500)> _
Public Class ConstructTopMenuBar
Inherits System.Web.UI.WebControls.WebControl
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
With oMenu
.ServerName = Page.Request.ServerVariables("server_name")
.IPAddress = Page.Request.ServerVariables("REMOTE_HOST")
.UserName = Page.Request.ServerVariables("logon_user")
.LoadPageInfo(Page.Request.ServerVariables("url"),
_ExecuteSecurity)
If _ExecuteSecurity = True Then
If .HasAccessToPage = False Then
MailSecurity()
Page.Response.Redirect("http://" &
Page.Request.ServerVariables("Server_Name") & "/intranet/securityNet.asp")
End If
End If
'************************************************* *************
' Dim cachedOutput As Object = context.Cache("TopMenuBar")
'If Not IsNothing(cachedOutput) Then
'output.Write(cachedOutput.ToString & " CACHED")
'Else
Dim strOutput As String = .ConstructTopMenuBar()
' context.Cache.Add("TopMenuBar", strOutput, Nothing,
Today.AddMinutes(2), TimeSpan.Zero, Web.Caching.CacheItemPriority.High,
Nothing)
'output.Write(strOutput & " not cached")
output.Write(strOutput)
' End If
'************************************************* **************
End With
oMenu.Dispose()
oMenu = Nothing
End Sub
End Class