initial add
This commit is contained in:
39
Fab2ApprovalSystem/Misc/SessionExpireFilterAttribute.cs
Normal file
39
Fab2ApprovalSystem/Misc/SessionExpireFilterAttribute.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
|
||||
namespace Fab2ApprovalSystem.Misc
|
||||
{
|
||||
public class SessionExpireFilterAttribute : ActionFilterAttribute
|
||||
{
|
||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||
{
|
||||
HttpSessionStateBase session = filterContext.HttpContext.Session;
|
||||
HttpContext ctx = HttpContext.Current;
|
||||
|
||||
|
||||
|
||||
// check if session is supported
|
||||
|
||||
|
||||
if (session[GlobalVars.SESSION_USERNAME] == null)
|
||||
{
|
||||
// check if a new session id was generated
|
||||
|
||||
// this will force MVC to use the standard login redirect, enabling ReturnURL functionality
|
||||
System.Web.Security.FormsAuthentication.SignOut();
|
||||
filterContext.Result = new System.Web.Mvc.HttpUnauthorizedResult();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
base.OnActionExecuting(filterContext);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user