본문 바로가기

프로그래밍/.NET

[ASP.NET] 로그아웃 후 뒤로가기 시 페이지 노출 해결

반응형



특정 페이지에서 로그아웃 후 다시 뒤로가기를 하면 해당 페이지가 다시 보여지는 문제를 해결해보자




  원인


캐시가 남아 있어서 그럴 것으로 판단됐다.

구글에 검색하여 가장 많이 나오는 meta태그를 이용하는 방법을 써보았으나 해결되지 않았다.

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Pragma" content="no-store">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">



  해결


Global.ascx의 시작 함수에 다음 코드를 적용

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();


반응형