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:
Action Filter Or Controller Filter
From this article we can learn how to disable the view of previous page after the logout.
Custom Action Filter Attribute:
public class NoCacheAttribute:ActionFilterAttribute
{
public override void
OnResultExecuting(ResultExecutingContext
cntxt)
{
cntxt.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
cntxt.HttpContext.Response.Cache.SetValidUntilExpires(false);
cntxt.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
cntxt.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
cntxt.HttpContext.Response.Cache.SetNoStore();
base.OnResultExecuting(cntxt);
}
}
[Authorize]
[NoCache]
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);
}
}
Output
After Logout if click the back button you can see that return url in concat in the url section
No comments:
Post a Comment