Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

FormsAuthentication.SignOut is NOT working

Posted on 2007-11-26
8
Medium Priority
?
3,720 Views
Last Modified: 2013-12-16
Hi..

I am trying to create logout link. When I click on the logout, it is taking me to the logon.aspx page. that is good. But, when i press the back button, it is taking me back to the default.aspx page - it should not.

This is what I have for logout:
        public void LoginLink_OnClick(object sender, EventArgs args)
        {
            Session.Abandon();
            Session.Contents.RemoveAll();
            FormsAuthentication.SignOut();
            FormsAuthentication.RedirectToLoginPage();
        }
and in the default.aspx page - form_load:
            if (HttpContext.Current.User.Identity.IsAuthenticated == false)
            {
                FormsAuthentication.RedirectToLoginPage();
            }

I also have some code in the void Application_AuthenticateRequest(Object sender, EventArgs e)
            String cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = Context.Request.Cookies[cookieName];
            if (null == authCookie)
            {//There is no authentication cookie.
                return;
            }
0
Comment
Question by:neonlights
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 7

Expert Comment

by:Maverick_Cool
ID: 20350526
Looks like the cookie still contains login information, hence erase it as part session out.
0
 

Author Comment

by:neonlights
ID: 20350545
how do I do that?
0
 
LVL 7

Expert Comment

by:Maverick_Cool
ID: 20350575
Try this:
Response.Cookies.Remove(FormsAuthentication.FormsCookieName);
0
Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

 

Author Comment

by:neonlights
ID: 20350600
Thanks Maverick... but, I can still do the back button.. I put remove code in:

            Session.Abandon();
            Session.Contents.RemoveAll();
            FormsAuthentication.SignOut();
            Response.Cookies.Remove(FormsAuthentication.FormsCookieName);
            FormsAuthentication.RedirectToLoginPage();
0
 
LVL 10

Accepted Solution

by:
Oliver Amaya earned 2000 total points
ID: 20350795
Hi, it may be an issue with the browser keeping a copy of the page in cache, when you press the back button I believe the normal chain of events in a request don't get fired, try adding the following line to the top of your page_load event to ensure that the browser always asks for the page in the server:
Response.Cache.SetCacheability(HttpCacheability.NoCache);

Open in new window

0
 
LVL 7

Expert Comment

by:Maverick_Cool
ID: 20350858
Do you have Aynonmous authentication on WebPAges check inetmgr
0
 

Author Comment

by:neonlights
ID: 20350968
Hi Joex911 - THANK YOU!....

Worked perfectly..

Thanks again.
0
 

Author Closing Comment

by:neonlights
ID: 31410992
Right on the target!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question