Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / March 2005

Tip: Looking for answers? Try searching our database.

GetVaryByCustomString - Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GFaux - 29 Sep 2004 12:25 GMT
Hi,

I've added an override for GetVaryByCustomString to global.asax:

       Public Overrides Function GetVaryByCustomString(ByVal context As
System.Web.HttpContext, ByVal custom As String) As String
           Dim sTemp As String
           Select Case custom
               Case "agent"
                   sTemp = "agent=test"
                   Return sTemp
           End Select
       End Function

In my aspx page (code behind) I have the following code:

Response.Cache.SetExpires(Now.AddSeconds(600))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetVaryByCustom("agent")

The problem is that GetVaryByCustomString never fires. Anyone seen this
before?

Any thoughts?

Regards,

Gavin
GFaux - 29 Sep 2004 14:43 GMT
Got it working by adding the appropriate @ OutputCache to the aspx page, but
now I have another problem:

How do I make sure a page is not cached?
MyBase.GetVaryByCustomString(context, custom) returns nothing, which should
mean that the page is not cached. but I can't get this to work. Any help
appreciated....

       Public Overrides Function GetVaryByCustomString(ByVal context As
System.Web.HttpContext, ByVal custom As String) As String
           Dim oParams As FAPCollection =
Utils.CreatePageParams(context.Request)
           Select Case custom
               Case "agent"
                   If oParams.Collection.Count = 2 Then
                       If oParams.ExistsKey("agentid") AndAlso
oParams.ExistsKey("opt") Then
                           Return "agent=" & oParams("agentid") &
oParams("opt")
                       End If
                   End If
           End Select
           Return MyBase.GetVaryByCustomString(context, custom)
       End Function

Thanks

Gavin
sudhir Sharma - 25 Mar 2005 21:23 GMT
Hi Buddy,
Did you find any solution to this problem. My problem is also same. the
Method "GetVaryByCustomString()" is not getting called. it is getting
called only twice. after that, control does not go to the method. Its
making me mad. I have this code in my .aspx file--
<%@ OutputCache Duration="100" VaryByCustom="ORGANIZATIONID"
VaryByParam="none"%>

Any help is appreciated.
Thanks
Sudhir

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.