c# - Possible way to make the page session expired in ASP MVC 3? ("Press Back Button after Logout issue" -


i working on mvc3 website user authentication.

i have security issue whereby want prevent user relogin pressing button after log out page.

i had research many solutions, not understand how apply project. possible in mvc3?

you not re-logging, viewing page browser cache. if try debug, see no code executed on button on browser. if try click after logging out , pressing back, redirected login page(if left default mvc3 app behavior).

there several solutions, , take:

  1. you can make custom actionfilterattribute, prevent caching on controllers, or/and actions this, apply action/controller:

    public class noclientcache : actionfilterattribute {     public override void onresultexecuting(resultexecutingcontext filtercontext)     {         filtercontext.httpcontext.response.cache.setexpires(datetime.utcnow.adddays(-1));         filtercontext.httpcontext.response.cache.setvaliduntilexpires(false);         filtercontext.httpcontext.response.cache.setrevalidation(httpcacherevalidation.allcaches);         filtercontext.httpcontext.response.cache.setcacheability(httpcacheability.serverandnocache);         filtercontext.httpcontext.response.cache.setnostore();          base.onresultexecuting(filtercontext);     } } 
  2. you can force refresh after logout executed triggering browser client-side

    history.go(1);

added: if logging out single location, should go first approach, if logout button on layout page, bad disable caching on pages, 2nd approach seems way go.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -