Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 676003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:52:49+00:00 2026-05-14T00:52:49+00:00

I have a requirement for an explicit logout button for users in a ASP.NET

  • 0

I have a requirement for an explicit logout button for users in a ASP.NET web app. I am using IIS6 with Basic Authentication (SSL). I can redirect to another web page but the browser keeps the session alive. I have googled around and found a way to do it by enabling an active x control to communicate with IIS and kill the session. I am in a restricted environment that does not allow forms authentication and active x controls are not forbidden as well. Has anyone else had this requirement and how have you handled it?

Okay that is what I was afraid of. I have seen similar answers on the net and I was hoping someone would have a way of doing it. Thanks for your time though. I guess I can use javascript to prevent the back button like the history.back()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:52:49+00:00Added an answer on May 14, 2026 at 12:52 am

    I was struggling with this myself for a few days.

    Using the IE specific ‘document.execCommand('ClearAuthenticationCache');‘ is not for everyone a good option:
    1) it flushes all credentials, meaning that the user will for example also get logged out from his gmail or any other website where he’s currently authenticated
    2) it’s IE only 😉

    I tried using Session.Abandon() and then redirecting to my Default.aspx. This alone is not sufficient.
    You need to explicitly tell the browser that the request which was made is not authorized. You can do this by using something like:

    response.StatusCode = 401;
    response.Status = "401 Unauthorized";
    response.AddHeader("WWW-Authenticate", "BASIC Realm=my application name");
    resp.End();
    

    This will result in the following: the user clicks the logout button ==> he will get the basic login window. HOWEVER: if he presses escape (the login dialog disappears) and hits refresh, the browser automagically sends the credentials again, causing the user to get logged in, although he might think he’s logged out.

    The trick to solve this is to always spit out a unique ‘realm’. Then the browser does NOT resend the credentials in the case described above. I chose to spit out the current date and time.

    response.StatusCode = 401;
    response.Status = "401 Unauthorized";
    string realm = "my application name";                
    response.AddHeader("WWW-Authenticate", string.Format(@"BASIC Realm={0} ({1})", realm, DateTimeUtils.ConvertToUIDateTime(DateTime.Now)));
    resp.End();
    

    Another thing that you need to do is tell the browser not to cache the page:

    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetExpires(DateTime.MinValue);
    Response.Cache.SetNoStore();
    

    With all these things in place it works (for me) in IE, but until now I still wasn’t able to prevent firefox from logging in the user when the user first presses escape (hides the basic login dialog) and then refresh (F5) or the browsers back button.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a load balanced (NLB) ASP.NET web app which sends email. The servers
I have requirement to show the pdfs to the users via asp.net application. These
I have requirement of creating MS Project object in asp.net c# and exporting image
We have created a Custom Capcha generator using C#.Net. Now we have requirement to
I have requirement of specifying web part connections in onet.xml. So when site is
I have requirement to import Excel file in MySQL database using Java. I Googled
Hi I have requirement to create ,compile and load java classes run time. Using
We have one project built upon asp.net framework 2.0. It is completely tested and
In my iPhone app, I have requirement to search the SQLite database. I will
I have a requirement that my app, can receive events (e.g. messages) from server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.