Advertisement
Guest User

Untitled

a guest
Jul 30th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
  2. public class SessionExpireFilterAttribute : ActionFilterAttribute
  3. {
  4. public override void OnActionExecuting(ActionExecutingContext filterContext)
  5. {
  6. HttpContext ctx = HttpContext.Current;
  7.  
  8. // If the browser session or authentication session has expired...
  9. if (ctx.Session["USER_ID"] == null )
  10. {
  11. filterContext.Result = new RedirectToRouteResult(
  12. new RouteValueDictionary {
  13. { "Controller", "Employer" },
  14. { "Action", "SessionTimeout" }
  15. });
  16.  
  17. }
  18.  
  19. base.OnActionExecuting(filterContext);
  20. }
  21. }
  22.  
  23. [SessionExpireFilter]
  24. public class EmployerController : Controller
  25. {
  26. //Action Methods
  27. }
  28.  
  29. This webpage has a redirect loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement