locked
User.Identity is null in MVC 5 application using windows auth RRS feed

  • Question

  • User853731431 posted

    Using VS 2015 and with an MVC 5 application, Im trying to use windows auth.  Ive done this before, but for some reason I cant get at the User identity.  Im using a base controller and in its constructor, Im using "User.Identity" and its null.  Thinking Im doing something wrong, I started a new project and set the properties to use windows auth, and this new project works fine AND I can set a breakpoint in the controller and see User.Identity populated.

    With the app that is not working, the project properties (hitting f4) I have both Anonymous enabled and windows disabled 

    When I hit my breakpoint in the base controller, User.Identity is null.  What can I check?

    Wednesday, March 2, 2016 9:07 PM

Answers

  • User1124521738 posted

    if you are using windows auth you have your security backwards, disable anon and enable windows, you can also leave both enabled if you put/update some stuff in the web.config:

    <system.web>

        <authentication mode="Windows" />
        <authorization>
            <deny users="?" />
        </authorization>

    </system.web>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 2, 2016 9:36 PM