I want disable my back button in internet explorer when i am logged out.. iam using asp.net platform for my project..
i hope u willl sent me the code which may be usefull
waiting for ur reply..
thank you

Dani AI

Generated

Browsers control navigation, so you cannot reliably turn the back button off. As and observed, client-side tricks are fragile and browser UI cannot be permanently suppressed. The practical, reliable goal is to prevent a logged-out user from seeing or acting on protected pages after logout.

Combine three server-side measures (sessions + cookies + cache-control) and a per-page authentication check. was right to point at sessions, and was on the right track with headers — but you need all of these together: properly sign out and abandon the session, expire auth/session cookies, set strict no-cache headers, and make every protected page verify authentication on each request (base page, master page or a global check).

Example logout handler (C# ASP.NET):

protected void Logout_Click(object sender, EventArgs e)
{
    System.Web.Security.FormsAuthentication.SignOut();
    Session.Clear();
    Session.Abandon();

    var authCookie = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName) { Expires = DateTime.UtcNow.AddDays(-1) };
    Response.Cookies.Add(authCookie);

    var sessCookie = new HttpCookie("ASP.NET_SessionId") { Expires = DateTime.UtcNow.AddDays(-1) };
    Response.Cookies.Add(sessCookie);

    Response.Redirect("~/Login.aspx", true);
}

Enforce on every protected page (put this in a base page or Page_Init):

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);

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

    if (Session["UserId"] == null || !Request.IsAuthenticated)
        Response.Redirect("~/Login.aspx", true);
}

Notes: put the checks early (Init) so the page does not render. ’s redirect idea can be part of the logout flow, but it does not replace server-side checks. For extra safety with cached browsers, have pages perform a small server-side session check (AJAX) on load and redirect if expired. Do not rely on client-side history tricks.

Recommended Answers

All 7 Replies

actually this type of out put is gained by using sessions .

actually this type of out put is gained by using sessions .

ya i have used session..
but not able to disable back button..
the coding i have used is
Response.buffer=true
Response.expires=60
response.ExpiresAbsolute= dateTime.noe.addsday(-1)
response.addHeader("{Pragma","no-cache")
response.addheader("cache-control","private")
response.cacheControl = "no-cache"
response.cache.setCacheability(Httpcacheability.Nocache)

After logged out ,if you click back button it should stay in same page or index page.no need to navigate any one of the login page.this is your need .Am i correct?

You cannot disable the back button. It is just not possible.

You can hide the bars with code, but by right clicking, the "back" link is still there.

You can disable the right-click but the backspace still sends you back a page.

You can disable the backspace event, and you thought of everything.

Except when the user goes to the internet explorer File -> View -> Toolbars...

And then you have to start all over again. Like I said, it's just not possible ^^

I do not think you would be able to disable the back button. My take is that you take a critical look at your design again so that it mitigates this problem.
I had the same problem some time ago and my research led to a dead end.
I had to redesign.
peace

you use one intermediate page to redirect.it solves your problem if your need like my previous reply.

<script type="text/javascript" language="javascript">
javascript:window.history.forward(1);
</script>

if you need no navigation in X page you will add this code in previous of X page.

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.