HttpContext.Current.User is Nothing in Application_AuthenticateRequest

Posted on 2008-11-04
Last Modified: 2012-08-14
Hi experts,

I have an ASP.NET application in develoment, that uses Forms Authentication.  I have written some code (based on an article from MSDN, if I remember correctly) to store role-information in a ticket in a coockie.

Then in the "Application_AuthenticateRequest" method of Global.asax, I used some information of HttpContect.Current.User to get back to the role-info that was stored in the ticket.

Now, after a few weeks when everything worked fine, all of a sudden the "HttpContect.Current.User" is always equal to Nothing, and I have no clue where to look.  I have checked that none of my security-related code has changed.


Question by:joriszwaenepoel
    LVL 20

    Expert Comment

    Have you recently moved to IIS 7? Have a look at this link, especially items 8 to 10:

    LVL 10

    Author Comment

    That's good to know, but I haven't changed the version of IIS.
    I am developing using VS2005, and the problem exists with the internal "visual studio development server" and also with the IIS Web Server.  That is why I think it must be a project setting or some programmatic change that caused this change in behaviour.

    I have found a workaround (keeping the roles in an session variable, instead of in the authentication ticket), but I would still like to know what caused this.  It could help to prevent similar problems in fututre projects.


    LVL 10

    Accepted Solution

    I found the reason why the code suddenly failed:
    As I added more roles to the application, the amount of data in the ticket increased, until it stopped working.  I discovered that by adding a user with less privileges, for who the original code still worked, then added more privileges until it suddenlmy stopped working.  So I guess there is a limit to the amount of data that can be stored in the ticket (in the coockie).

    I now store the role-information in a session variable, ans use that instead.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now