Hi -
I've tried a whole bunch of suggestions I found on msdn to get my site to redirect to a login page when my session expires but I haven't had any luck. Does anyone know a standard way to so this that is consistent.
My webconfig settings are:
<authentication mode="Forms">
<forms loginUrl="~/Login/Login.as
px" name="adAuthCookie" timeout="1" path="/">
</forms>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
Global.asax
void Application_AuthenticateRe
quest(obje
ct sender, EventArgs e)
{
string cookieName = FormsAuthentication.FormsC
ookieName;
HttpCookie authCookie = Context.Request.Cookies[co
okieName];
if (null == authCookie)
{
//There is no authentication cookie.
return;
}
FormsAuthenticationTicket authTicket = null;
try
{
authTicket = FormsAuthentication.Decryp
t(authCook
ie.Value);
}
catch (Exception ex)
{
//Write the exception to the Event Log.
return;
}
if (null == authTicket)
{
//Cookie failed to decrypt.
return;
}
//When the ticket was created, the UserData property was assigned a
//pipe-delimited string of group names.
string[] groups = authTicket.UserData.Split(
new char[] { '|' });
//Create an Identity.
GenericIdentity id = new GenericIdentity(authTicket
.Name, "LdapAuthentication");
//This principal flows throughout the request.
GenericPrincipal principal = new GenericPrincipal(id, groups);
Context.User = principal;
}
protected void Session_End(Object sender, EventArgs e)
{
//having problem with this -- page is not being re-directed when the session expires
//need to check session state on each page?
Response.Redirect("Login.a
spx");
}
Start Free Trial