c# - How to clear browser cache on browser back button click in MVC4? -


i know popular question in stackoverflow. have gone through every same question , unable find right answer me. log out controller action result

    [authorize]            public actionresult logout(user filtercontext)     {         session.clear();         session.abandon();         session.removeall();         response.cache.setcacheability(httpcacheability.nocache);         response.cache.setexpires(datetime.utcnow.addhours(-1));         response.cache.setnostore();         formsauthentication.signout();         return redirecttoaction("home", true);      } 

it didn't work me. tried adding-

<meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="pragma" content="no-cache"/> <meta http-equiv="expires" content="0"/>

none of these resolved issue.

the problem approach setting late mvc apply it. following 3 lines of code should put in method shows view (consequently page) not want show.

response.cache.setcacheability(httpcacheability.nocache); response.cache.setexpires(datetime.utcnow.addhours(-1)); response.cache.setnostore(); 

if want apply "no cache on browser back" behavior on pages should put in global.asax.

protected void application_beginrequest() {     response.cache.setcacheability(httpcacheability.nocache);     response.cache.setexpires(datetime.utcnow.addhours(-1));     response.cache.setnostore(); } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -