Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
i have implemented form authentication, its working fine,get succefully logout and dont return bcak to welcome page, but in case my welcome page get post back once then, i click on logout button its get logout but, when i click on browser back button it returns back to my welcome page.
Posted

1.In your Page_Init and Page_Load of your Login.aspx.cs page, used for form authentication add the code like in the next example.
C#
 protected void Page_Init(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //
         // Clear the session cached data
         //
         Session.Clear();
     }
 }

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        FormsAuthentication.SignOut();

    }
    //....
}

2.In your web.config you must set form authentication like in the next example:
XML
<authentication mode="Forms">
  <forms loginUrl="Login.aspx" timeout="2880" />
</authentication>

3.In your master page the LoggedInTemplate section must be similar with the next code:
XML
<LoggedInTemplate>Hello<span class="bold">
                                        <asp:LoginName ID="HeadLoginName" runat="server" />
                                    </span>! [
                                    <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Logout"
                                        LogoutPageUrl="~/" />
                                    ]
</LoggedInTemplate>

4.At the logout time, you could delete the browser cache as is indicated in the next article:
http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers[^]
 
Share this answer
 
v4
Comments
Sunil Kumar 4-Sep-14 13:17pm    
i have tried it already.. btw thnxx. do u have another solution ?
Session.Abandon();
Session.Clear();
FormsAuthentication.SignOut();
Raul Iloc 5-Sep-14 0:56am    
See my update with details code!
Raul Iloc 5-Sep-14 3:35am    
1.The source code from my solution should work, maybe you missed something, like clearing the browser cache before to testing the changes.
2.Your site is not accessible from the internet, so I cannot have a look on it.
Sunil Kumar 5-Sep-14 4:17am    
sorry i did mistake ..

http://www.readyfabrics.com/admin.aspx
Raul Iloc 5-Sep-14 8:23am    
I have checked your site and the page from browser cache is used, but if your try any action in the page from cache you will be redirected to login page. To fix also this problem see my update (4th point)!
You need to clear browser history.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900