Browser Back Button Working After Logout from Asp.Net application

Category > ASP.NET || Published on : Wednesday, September 24, 2014 || Views: 8685 || Browser Back Button Working After Logout from Asp.Net application Browser Back Button Logout

While begin logout from the web application a use can still move to the previous page using the browsers back button.During the log out event, Session is cleared and caching is disabled but the previous page is still shown. So, how can we work around this?

All browsers provide the History Option to go back to previous visited web pages(both forward and backward). The browser cache the visidted page and the History butons-  backward and forward is used to to move from oder visted pages to newer visited page.

So, to fix this type of issue, we need to make sure that page do not get cahced. I'm showing to method to resolve this issue.

Option 1 - Code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class option_one : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

Option 2 - Works on any page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="option-two.aspx.cs" Inherits="option_two" %>

"-//W3C//DTD XHTML 1.0 Transitional//EN" "">

"Head1" runat="server">
        "Cache-Control" content="no-cache" />
        "Pragma" content="no-cache" />
        "Expires" content="0" />

    "form1" runat="server">

In the above code, you can paste the code in the master page for the authenticated pages or alternatively, if there is no fixed master page for authenticated pages - then, it needs to be places on all all required pages.

so, we have learned and resolve the issue related with Browser Back Button Working After Logout from Asp.Net application


Download Source Codes