i want to display session time out message on my LogOn page.
i have override asp.net mvc Authorize attribute to naviagate the user to logOn page on session timeOut but my problem is that i am not able to set ViewData or ViewBag or Session[“Message”]
kind of thing inside that override method.
i would request you all to please help me …
how to set ViewData inside that Override method.
below is my CustomAuthorizeAttribute class
public class CustomAuthorizeAttribute : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext == null)
{
throw new ArgumentNullException("filterContext");
}
if (!filterContext.HttpContext.User.Identity.IsAuthenticated || SessionCache.User_ID == 0)
{
// User not logged in, redirect to login page
filterContext.Result = new HttpUnauthorizedResult();
return;
}
}
}
please suggest.
thanks,
You want to look into using Session_End event in your Global.asax.
It’s important to realize that Session_End will only be called on InProc sessions.