L
Luis Esteban Valencia Muñoz
Hi all
I have as Asp.Net app that uses FormsAuthentication to authenticate the
users.
My page is composed by a Web Control that shows the name of the user that is
logged on. This name is saved on a "Session Variable".
The page that holds this WebControl have the folowing Cache Directive:
<%@ OutputCache Duration="300" VaryByParam="none" VaryByCustom="CookieUser"
%>
And, on my Global.asax, i have the implementation of the
GetVaryByCustomString function:
Public Overrides Function GetVaryByCustomString(ByVal context As
HttpContext, ByVal arg As String) As String
If (arg.ToLower = "cookieuser") Then
Dim cookie As HttpCookie
cookie =
context.Request.Cookies(FormsAuthentication.FormsCookieName)
'Do we have a cookie?
If IsNothing(cookie) = False Then
Debug.WriteLine(Now & " - " & cookie.Value)
Return cookie.Value
End If
Return MyBase.GetVaryByCustomString(context, arg)
End If
End Function
On the function above i put the Debug.Write method to see when the
cookie.value is requested.
When UserA logs on the system, my page shows its name correctly. Now, i will
logout from my system, and its execute the folowing methods:
Session.Abandon()
FormsAuthentication.SignOut()
Response.Redirect("pLogin.aspx", True)
So, i will login as UserB. The page is loaded from the cache instead from
being regenerated. The system doen't make a call to GetVaryByCustomString
and shows me the name of UserA. If i press F5 (refresh the page), the
GetVaryByCustomString is called and now the page shows the UserB name...
Shouldn't I automatically have 2 versions of the same page, because if have
2 distincts cookie.values???
This problem is making me crazy.... Does anybody has any idea???
Thanks all!!!
I have as Asp.Net app that uses FormsAuthentication to authenticate the
users.
My page is composed by a Web Control that shows the name of the user that is
logged on. This name is saved on a "Session Variable".
The page that holds this WebControl have the folowing Cache Directive:
<%@ OutputCache Duration="300" VaryByParam="none" VaryByCustom="CookieUser"
%>
And, on my Global.asax, i have the implementation of the
GetVaryByCustomString function:
Public Overrides Function GetVaryByCustomString(ByVal context As
HttpContext, ByVal arg As String) As String
If (arg.ToLower = "cookieuser") Then
Dim cookie As HttpCookie
cookie =
context.Request.Cookies(FormsAuthentication.FormsCookieName)
'Do we have a cookie?
If IsNothing(cookie) = False Then
Debug.WriteLine(Now & " - " & cookie.Value)
Return cookie.Value
End If
Return MyBase.GetVaryByCustomString(context, arg)
End If
End Function
On the function above i put the Debug.Write method to see when the
cookie.value is requested.
When UserA logs on the system, my page shows its name correctly. Now, i will
logout from my system, and its execute the folowing methods:
Session.Abandon()
FormsAuthentication.SignOut()
Response.Redirect("pLogin.aspx", True)
So, i will login as UserB. The page is loaded from the cache instead from
being regenerated. The system doen't make a call to GetVaryByCustomString
and shows me the name of UserA. If i press F5 (refresh the page), the
GetVaryByCustomString is called and now the page shows the UserB name...
Shouldn't I automatically have 2 versions of the same page, because if have
2 distincts cookie.values???
This problem is making me crazy.... Does anybody has any idea???
Thanks all!!!