Thursday, August 6, 2009

Action Filter in MVC to solve problem of Authentication Timeout

Add an Action Filter in MVC to solve problem of Authentication Timeout. Once Authentication Timeout then redirect to another place.
public class AuthenticationTimeoutFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting( ActionExecutingContext filterContext ) {
HttpContext context = HttpContext.Current;
if (!context.User.Identity.IsAuthenticated)
{
context.Response.Redirect("~/ControllerName/ActionName");
}
base.OnActionExecuting ( filterContext );
}
}


Forms Authentication timeout default in ASP.NET 2.0

No comments:

Post a Comment