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 802359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:35:19+00:00 2026-05-14T23:35:19+00:00

I am experimenting with FormsAuthentication (using ASP.NET MVC2) and it is working fairly well.

  • 0

I am experimenting with FormsAuthentication (using ASP.NET MVC2) and it is working fairly well.

However, one case I can’t work out how to deal with is validating the user identity on the server to ensure it is still valid from the server’s perspective.

eg.

  1. User logs in … gets a cookie/ticket
  2. Out of band the user is deleted on the server side
  3. User makes a new request to the server. HttpContext.User.Identity.Name is set to the deleted user.

I can detect this fine, but what is the correct way to handle it? Calling FormsAuthentication.SignOut in the OnAuthorization on OnActionExecuting events is too late to affect the current request.

Alternatively I would like to be able to calls FormsAuthentication.InvalidateUser(…) when the user is deleted (or database recreated) to invalidate all tickets for a given (or all) users. But I can’t find an API to do this.

  • 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-14T23:35:20+00:00Added an answer on May 14, 2026 at 11:35 pm

    In the global.asax, add an handler for AuthenticateRequest. In this method, the forms authentication has already taken place and you’re free to modify the current principal before anything else happens.

    protected void Application_AuthenticateRequest(object sender, EventArgs e) {
      IPrincipal principal = HttpContext.Current.User;
      if (!UserStillValid(principal)) {
        IPrincipal anonymousPrincipal = new GenericPrincipal(new GenericIdentity(String.Empty), null);
        Thread.CurrentPrincipal = anonymousPrincipal;
        HttpContext.Current.User = anonymousPrincipal;
      }     
    }
    

    Just implement the UserStillValid method and you’re done. It’s also a good place to swap the generic principal with a custom one if you need to.

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

Sidebar

Related Questions

I'm experimenting with ASP.Net Web API, which, by convention, splits controller methods into a
I experimenting with WebView in Android and I can't figure out how to make
I experimenting with jQuery. As I was trying I found out that I can't
Experimenting with android game development. I'm using PNG format for images, and was wondering
I'm experimenting with Spring Mobile but I can't seem to get the basic example
been experimenting with unordered list UL and i have seem varios examples of using
Experimenting with a battery monitor icon at the moment in Python using pygtk and
After experimenting with some triangulation work I ran across the question on how to
I experimenting with JavaFX. Since JDK 1.7 JavaFX is now part of JRE, however,
I am experiencing a strange problem with asp.net forms authentication. This problem only occurs

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.