Kumar AU

Kumar AU

  • 1.1k
  • 320
  • 63.2k

On session Timeout My page is not getting refreshed - MVC 4

Jun 13 2017 9:32 PM
I have already set the session time in web.Config file, after the session time out I want my page automatically to get refreshed and redirect to Login page, but its not happening, kindly find my code as mentioned below :- Pleaes help me , I have been trying since almost 1 week, but no progress.
HttpContext ctx = HttpContext.Current;
if (ctx.Session != null)
{
// check if a new session id was generated
if (ctx.Session.IsNewSession)
{
HttpContext ctx1 = HttpContext.Current;
// check sessions here
if (ctx.Session["UserName"] == null || !filterContext.HttpContext.Request.IsAuthenticated)
{
if (filterContext.HttpContext.Request.IsAjaxRequest())
{
FormsAuthentication.SignOut();
filterContext.Result = new RedirectResult("~/Authentication/Logon");
base.OnActionExecuting(filterContext);
}
}
}
}

Answers (1)