What is the best way to redirect a You can do anything like this: If you want to use then you have a public Then your filter will look something like this: ActionFilterAttribute ? I have
ActionFilterAttribute
named "IsAuthenticatedAttributeFilter" and checked the value of a session variable. If the variable is wrong, then I want to redirect the application to the login page. I prefer to redirect using the root name
SystemLogin , but at this point any redirect method will be cured.
filterContext.Result = new ViewResult {ViewName = SharedViews.SessionLost, ViewData = filterContext.Controller.ViewData} ;
RedirectToAction :
RedirectToAction method You can create your controller ( preferably on your base controller ) which only calls secure
RedirectToAction to
System.Web.Mvc.Controller . Adding this method allows public call your
redirect action from the filter.
Redirect the new redirect reader redirects action (string action, string controller) {return base. Redirection projection (action, controller); }
Public override zero on anchoring (Action Accepting Contact Filter Contact) {var Controller = (some control) filterContext.Controller; FilterContext.Result = controller.RedirectToAction ("index", "home"); }
Comments
Post a Comment