Friday, 10 January 2014

Disable the view of page while click back button after Logout using custom action filter

In this article we are going to how to avoid the user to view the page while click the back button after log out, To do this we have to enable the clear the cache and expires the cache. So create the custom action filter to restrict the user to go for view the previous page.

Custom Action Filter Attribute:
public class NoCacheAttribute:ActionFilterAttribute
      public override void  OnResultExecuting(ResultExecutingContext cntxt)
     cntxt.HttpContext.Response.Cache.SetValidUntilExpires(false);                cntxt.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);

Action Filter Or Controller Filter

    public class EmployeeController : Controller
        Models.EmpModel mod = new Models.EmpModel();

        public ActionResult Create()
            return View();

        public ActionResult Index()
            List<EMPTABLE> result = mod.GetEmployees();
            return View(result);


After Logout if click the back button you can see that return url in concat in the url section

From this article we can learn how to disable the view of previous page after the logout.

No comments:

Post a Comment