Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- routes.MapRoute(
- "Index2Redirect",
- "HomeController/Index2",
- new { controller = "HomeController", action = "Index", id = "" }
- );
- public class AbandonSessionAttribute: ActionFilterAttribute
- {
- public void OnActionExecuting(ActionFilterContext context)
- {
- if (Session.User.IsAuthenticated || Session.Count > 0) // <<-- this is the important line
- {
- Session.Clear();
- FormsAuthentication.SignOut(); // and so on
- context.Result = new RedirectResult("/Index2");
- }
- }
- }
- // now, if this is called with non-empty session, it will be cleared and user will be redirected again here
- [AbandonSession]
- public ActionResult Index2()
- {
- }
- Index()
- {
- expire all session and forms-Authententication cookies
- }
- Index2()
- {
- if(Session.IsNewSession)
- {
- redirect to Index action
- }
- else
- {
- Show view
- }
- }
Add Comment
Please, Sign In to add comment