Clear Output cache..??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Question123
    New Member
    • Feb 2008
    • 41

    #1

    Clear Output cache..??

    Hi
    i have added a tag to the asp.net page .aspx
    <%@ OutputCache Duration="600" VaryByParam="*" %>

    it caches the whole page. But problem is that after logout its not getting cleared and if i tried to loggin with some other user it shows old data cached for previous user.

    Please give me solution so that i can clear Output cache on user logout.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    If the logout is destroying the session correctly, then you can tell ASP.NET to cache pages for the current session only.

    First you need to add VaryByCustom=”S essionID” to the OutputCache directive. Then you simply override (in global.asax) GetVaryByCustom String to return that sessionID.
    something like:
    [code=asp.net]
    Public override string GetVaryByCustom String(HttpCont ext context, string arg) {

    if(arg.ToLower( ) == “sessionid ”) {
    HttpCookie c = context.Request .Cookies[“ASP.NET_Sessio nID”];
    if(c != null) return c.Value;
    }
    return base.GetVaryByC ustomString(con text, arg);
    }
    [/code]


    P.S: I'm not a .NET programmer so you need to verify that my code is syntactically correct

    Comment

    Working...