IIS Error 401.0 - Unauthorized after upgrade to Windows 11

Luis 131 Reputation points
2024-03-07T21:53:24.8+00:00

Hello everyone. I have an old intranet website that is currently working on Windows Server 2019. The site is an ASP.Net Web App using .Net Framework 4.7.2. I need to make minor cosmetic changes to it. When I test the source code on VS2019 or VS2022 it works fine, when I publish to my local IIS or the 2019 server, I get error "401.0 Unauthorized".

I'm using Anonymous Authentication, the DefaultAppPool has Write, Read and Execute access to the root folder where the site has been published. DefaultAppPool uses ApplicationPoolIdentity. Same settings are in the working site that is on the server.  I tried to create a trace, but it says 401.0 is not a valid code, I use a range from 400 to 500.1 and did not write anything on the log. Fiddler didn't help much either.

If I create a new demo site and publish it in both my local computer and the server, it works fine. Is there anything else that I can do to correct this issue?

Thank you.

Luis

Internet Information Services
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,537 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Luis 131 Reputation points
    2024-03-08T16:21:35.12+00:00

    Thanks @Lex Li (Microsoft) and @Sam Wu-MSFT , I found the culprit for this issue. The line shown below was at the top of my HomeControler. This was a leftover code from when this app was running on Azure at one point, in other words, my fault.

    Thank you.

    [System.Web.Mvc.Authorize]
    
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.