FormsAuthentication authCookie is null for some users only

I am having a weird issue with asp.net forms authentication. This problem occurs only for 3 users out of 30+ users who have successfully logged in. I am using very simple auth code that I have used many times and have never seen this problem. After successful user authentication and the creation of the auth cookie, a cookie is added and response.redirect is called for FormsAuthentication.GetRedirect (userid, false). The Application_AuthenticateRequest method in Global.asax is called.

// Extract the forms authentication cookie
        string cookieName = FormsAuthentication.FormsCookieName;
        HttpCookie authCookie = Context.Request.Cookies[cookieName];

        if (null == authCookie)
        {
            // There is no authentication cookie.
            return;
        }

So, immediately after saving a “good” cookie and redirecting the cookie, it is null. I ran the code through a debugger and the cookie only has a null value for these 3 users. But a cookie looks like a cookie to many users who have successfully logged in.

Any ideas? This is the standard code that should work.

+5
source share
1 answer

Are you sure that the “good” cookie is saved and leaves the response? In FormsAuthentication, you can add a good cookie to the header, but the response is deleted due to some other system error (for example, w3wp.exe failed), so a new response is generated without a cookie and redirected anyway.

Principal, ( cookie), cookie cookie .

+2

All Articles