hi,
I m doing project in ASP.Net so i want code which how i m clear the history of IE plz rply

Dani AI

Generated

: you cannot force-delete a user's Internet Explorer "History" from server-side ASP.NET code — that is a user/OS-level action and blocked for privacy and security. What you can do is make sure sensitive pages are not cached or re-displayed by the browser, and make the logout flow remove pages from the session history so the Back button cannot reveal protected content.

Responses from , and point in the right direction: invalidate the session on logout, stop pages from being stored by the browser, and avoid serving protected content from a cached copy. Combine server-side cache-control with a client-side history replacement on logout. For example, after ending the session send a non-cacheable response and then replace the current history entry before redirecting:

<script>
  // on the logout page (client-side)
  history.replaceState(null, '', '/login.aspx');
  location.replace('/login.aspx');
</script>

Also enforce a server-side check on protected pages so any request without a valid session is redirected to login (this prevents a cached page from acting as a substitute for proper authentication). Test in IE with F12 developer tools and InPrivate windows to confirm behavior. For details on HTTP caching headers and the History API, see the MDN references for Cache-Control and replaceState and the .NET HttpCachePolicy docs:

Recommended Answers

All 3 Replies

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
add this to your aspx page or
in code behind add this one

response.expires = 0
response.cache.setnostore()
response.appendheader("Pragma", "no-cache")

hope that helps

you can also do with C# code for clearing cache.

string cacheKey;
IDictionaryEnumerator CacheEnum = HttpContext.Current.Cache.GetEnumerator();
 while (CacheEnum.MoveNext())
                {
                    cacheKey = CacheEnum.Key.ToString();
                    HttpContext.Current.Cache.Remove(cacheKey );
                }

To clear history using java script code just try following code.
<%
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"

If Len(Session("FirstTimeToPage")) > 0 then

Session("FirstTimeToPage") = ""
Response.Redirect "home.aspx"'home page
Response.End
End If


%>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.