Unable to get the following standard code to work. Looking for a complete sample project or help on how to bug. The following code...
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.HttpContext.Session != null)
{
if (filterContext.HttpContext.Session.IsNewSession)
{
string cookie = filterContext.HttpContext.Request.Headers["Cookie"];
if ((cookie != null) && (cookie.IndexOf("_sessionId") >= 0))
{
filterContext.Result = newRedirectResult("~/SessionExpired/Index"); //redirect anywhere to message user UI , never hits this breakpoint
return;
}
}
}
base.OnActionExecuting(filterContext);
}
is standard for checking session expiration.
However in my case the the line (cookie != null) && (cookie.IndexOf("_sessionId") >= 0)
always returns false and thus the user is never redirected.
I am testing with a brand new wizard created MVC 4 project. I cannot find a complete download sample. I suspect my config my be wrong.
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="1" slidingExpiration="true" name=".ASPXFORMSAUTH" />
</authentication>
<sessionState mode="InProc" timeout="1" cookieless="false"/>
Please advise why this code fails or provide a link with a complete download sample project. .Net 4.5 | VS 2012 | local IIS Web Server , IIS Express