locked
Windows Authentication not working in ASP.NET RRS feed

  • Question

  • User755566206 posted

    Hi All

    I am trying to get the username of the user accessing the intranet site. Everything I looked at on the internet said to enable windows authentication and disable anonymous authentication. However, when I do this my web application fails with an error of "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.".

    If I enable anonymous authentication then the page opens as expected but I get the "IIS APPPOOL\DefaultAppPool" user being pulled back and not the users username as I would expect.

    Any help on how to fix this will be very much appreciated.

    Thanks

    Monday, July 4, 2016 12:42 PM

Answers

  • User755566206 posted

    Hi Guys

    Thanks for your advice. Tried what you suggested but nothing helped. I found this link that had the same issue as I was having and this fixed the problem.

    Basically in the Startup.cs file there is a ConfigureAuth method that tries to open a login form if a cookie has not been created. The app.UseCookieAuthentication part of the Startup.Auth.cs file needed to be removed and now it works fine.

    Thanks again for your time and effort.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 5, 2016 12:19 PM

All replies

  • User-782232518 posted

    You must disable anonymous and enable Windows authentication.

    To check why you see the error message of "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." please do more debugging of your code.

    Tuesday, July 5, 2016 5:40 AM
  • User36583972 posted

    Hi Dazza272,

    Dazza272

    I am trying to get the username of the user accessing the intranet site

    Yes, it is possible if you're using Windows Authentication in your application.

    You can refer the following links.

    Recipe: Enabling Windows Authentication within an Intranet ASP.NET Web application:

    http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application

    Getting A Users Username in ASP.NET:

    https://richhewlett.com/2011/02/15/getting-a-users-username-in-asp-net/

    Dazza272

    "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.".

    I suggest you can check whether the user id have permissions to access your pages.

    Best Regards,

    Yohann Lu

    Tuesday, July 5, 2016 6:43 AM
  • User755566206 posted

    Hi Guys

    Thanks for your advice. Tried what you suggested but nothing helped. I found this link that had the same issue as I was having and this fixed the problem.

    Basically in the Startup.cs file there is a ConfigureAuth method that tries to open a login form if a cookie has not been created. The app.UseCookieAuthentication part of the Startup.Auth.cs file needed to be removed and now it works fine.

    Thanks again for your time and effort.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 5, 2016 12:19 PM