Guest User

Untitled

a guest
Feb 18th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. public class LoginFiltro : ActionFilterAttribute
  2. {
  3. public override void OnActionExecuting(ActionExecutingContext filterContext)
  4. {
  5. object usuarioLogado = filterContext.HttpContext.Session["Nome"];
  6.  
  7. if (usuarioLogado == null)
  8. {
  9. filterContext.Result = new RedirectToRouteResult(
  10. new RouteValueDictionary(
  11. new { action = "Index", controller = "Login" }));
  12. }
  13. }
  14. }
  15.  
  16. [LoginFiltro]
  17. public class Login: Controller { }
Add Comment
Please, Sign In to add comment