.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

logout problem(after logout when clicking on back button after logout still opens the previous page

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
I am using ASP.NET, the web page is abandoning and clear session when a user click logout link but they click the back button and it is still showing the previous page. How can it prevent the previous page after logout?on Logout.aspx load im using this code//=================//        Session.Clear();        Response.Buffer = true;        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1D);        Response.Expires = -1500;        Response.CacheControl = "no-cache";        //----- Second Technique : To Stop Caching of Secure Pages.        Response.Cache.SetCacheability(HttpCacheability.NoCache);        FormsAuthentication.SignOut();        if (Session["UserName"] == null)        {            Response.Redirect("login.aspx");        }       Session.Clear();         Response.Buffer = true;         Response.ExpiresAbsolute = DateTime.Now.AddDays(-1D);         Response.Expires = -1500;         Response.CacheControl = "no-cac

View Complete Post

More Related Resource Links

After logout is done check is made so that the browser back button does not retun to the last visite


Why this code not working.I want after logout is done check  the browser back button does not retun to the last visited page.

please help me.

 <script language = "javascript" type = "text/javascript">

         -- After LOGOUT is done,check is made so that the browser back button
         does not retun to the last visited page.
         -- The below function is called in OnClientClick of Login button
         function SetLogoutCookie(value) {
             var exdate = new Date();
             exdate.setDate(exdate.getDate() + 1);
             var expires = "; expires=" + exdate.toGMTString();
             document.cookie = "logout=" + value + expires + "; path=/";

error when logout my web page

sir i am usinng ajax roundcorners toolkit but when i logout my web page error occuers . error is:- Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'AjaxControlToolkit.RoundedCornersBehavior' cannot be converted to type 'AjaxControlToolkit.RoundedCornersBehavior'. Parameter name: instance

logout action problem in IE

I have a login page and a default page to be redirected to after login. when I clicked on thew logout button in the default page it correctly redirects to login page. But when I click the back button in the IE I can again see the protected default page( in mozilla everythng is OK, no problem but in IE this problem occurs).Have I done something wrong. My code r below:login page===========protected void Login1_LoggedIn(object sender, EventArgs e)        {            if (Roles.IsUserInRole(Login1.UserName, "Members")) {               Response.Redirect("users/Member/default.aspx");                //Server.Transfer("users/Member/default.aspx",true);                        }        }===========default page has a LoginStatus button( logout action: RedirectToLoginPage)

Page does not post back when clicking any button

I thought the page was working fine yesterday. Today I added some code in various places and now a click on any button does not post back.

What could I check that has changed? Any suggesyions? Thank you.

how to clear history of a page when logout


i am creating a web application,when a user clicks logout it clears the session and also succesfully logsout,but when i press back button on browser it again shows the user is loged in,how to avoid this

Logout problem



I am working on asp.net projects and I am unable to solve logout problem.  I am facing this problem in my every project.  What I always do is, I create logout.aspx page for logout so that when user click on logout, it will redirect to this logout.aspx page where I write code for logout and then It will navigate to index page.  But when we click back button of the browser,  we can view that page. But if we click on any link of that page then it not works and it navigate to index page.  What my problem is after logout why it shows previous page while click on back button of browser?  Here is that code which I wrote in logout.aspx.cs file,

protected void Page_Init(object sender, EventArgs e)

logout button


i created a logout button in my website when i click that it will go to login button and also it will clear cache,session but when i click on back button of browser it showing the last page and also the data that i enterd how can i disable back button of browser 

some code i tried

Session.Clear();//clear session
        Session.Abandon();//Abandon session

Create HTML logout button



Is there a way to create a button that logs a user out (erasing session data) and redirects them using a list tag of this sort:

<li><a href="Login.aspx">Login</a></li>


Non-updatable page fields in the previous pages when clicked on back button.



I have the  following scenario.

I have four pages and user enters certain information and navigates to  the next page. In the last page, when user clicks on submit button it will redirect him to the confirmation page. Once the user is in the confirmation page and clicks on back button, all the fields in the previous pages must be non-updatable.

Note: User can use the back button to view his previous data but not-updatable anymore.

Can you please post some code for the above scenario ?

Clickin back or forward after Logout



I need a VB code to prevent the user from accessing the page if not authenticated  just like facebook when user click logout and if he click the back button user is redirected to login page

i need the same but in ASP.net

 i am using 


If Session("userid") Is Nothing Then




"default.aspx")End If



How to redirect my page to login page on Logout ?



In logout link's click event i have written Session.Abandon() that will destroy the Session state.I am also handling Session_End event that is fired afterward (written in Global.asax). But one more thing i want is that after Session ends, login page should be redirected (opened).

For that i wrote:

 Protected Sub logOut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles logOut.Click

End Sub

This is working fine on the surface, but after applying debugging i saw that there were unexpected number of  calls to Session_Start and Session_End events for two times, then login page was opened.

Why Session_Start and Session_End was called two times ? If i left this process as it is working then may i get some serious error in future ?

Problem with logout



Initillay my code was working fine when and I was able to logout from the application.

But since the time I have added below line of code, I am not able to logout from the application. The Logout status becomes Login but
I was able to do all the work that a Logged In person can do. I dont know how to handle this please help me. I beleive that Page_PreInit and
and OnInit methods are creating problem but I dont know how to overcome this problem.

protected void Page_PreInit(object sender, EventArgs e)
 Control myControl = null;
            myControl = GetPostBackControl(Master.Page);
            if ((myControl != null))
                if ((myControl.ID.ToString() == "ButtonToAddFileUploadControl"))
                    minimumFileUploadControlCounts = minimumFileUploadControlCounts + 1;

        catch { }

protected override void OnInit(EventArgs e)
        dynamicFileUpload = new FileUpload[minimumFileUploadControlCounts];
        int i;
        for (i = 0; i < minimumFileUploadControlCounts; i += 1)
            FileUpload fileUpload = new FileUpload();
            fileUpload.ID = "myFileUpload" + i.ToString();

Auto logout and redirect to login page when session expires using asp.net

In this article I will explain you how to auto logout and redirect to login page when users session expires within specific period.

Logout not redirecting correctly


I have the following control on my master page


asp:LoginStatus ID="LoginStatus1" runat

Problem when I back to page


Hi Friends

I have page A.aspx where I show some result in listview. When I click On Some data on listview I go to page B.aspx.

Now the problem is when I click on back in page B.aspx it comes to A.aspx with out previous listview result. Ack requirement is when I come to page A.aspx result of listview has to be there. How do i do that?

Could u please help me out?



Close Tab doesn't logout


When closing my tab, Formsauthentication doesn't clear, thanks!

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)

      if (Classes.CStaticDataAccess.AuthenticateUser(Login1.UserName, Login1.Password))
        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, Login1.UserName, DateTime.Now, DateTime.Now.AddMinutes(1), false, "");
        string secureTicket = FormsAuthentication.Encrypt(ticket);
        HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, secureTicket);
        string redirectUrl = FormsAuthentication.GetRedirectUrl(Login1.UserName, false);

       // System.Web.Security.FormsAuthentication.SetAuthCookie(Login1.UserName, false);
        e.Authenticated = true;

        e.Authenticated = false;

 <authentication mode="Forms">
      <forms name=".ASPXFORMSAUTH" loginUrl="~/Ware2Login.aspx" protection="All" timeout="30" path="/" ></forms>
      <deny users="?"/>

Redirecting to custom page while clicking on the user/group browse button

Hi, i have created a custom visual web part in visual studio 2010 and i deployed it into sharepoint site by creating a new page in my site. The custom page gets the data of users/groups from database and pass the users to the people picker in sharepoint.Here my question i have a document library where we upload document and get the users page popup that consists of people picker and a user/group browse button.when i click on the (book image button)browse button it will redirect to the user and group search page but here i need to replace my custom  user/group search page with the default one so please help me how to redirect to the custom page by clicking on the user/group browse button,and i need to pass the selected users to the people picker text box........please give me some solution whether this can be done or not if possibe please send me the link or some sample code how to do this   thank you.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend