Search code examples
c#asp.net-core-mvc-2.1

.NET CORE 2 MVC UseStatusCodePagesWithReExecute Windows Auth 401 issue


I am trying to implement UseStatusCodePagesWithReExecute. I have it set up and it works...but perhaps too well. I am using Windows auth and IIS with anonymous access disabled. The problem is that when the site comes up it automatically goes to the error page due to a 401 unauthorized (which does make sense). I should be getting the built in login prompt. When I comment out the middleware in my startup class I get the login prompt and all is good. Is UseStatusCodePagesWithReExecute not a good choice for this? Am I missing something to make it work with Windows auth?


Solution

  • Derp...I figured it out. Immediately after posting the question I went and looked at the web project settings and found that the IIS Express settings had Allow Anonymous Authentication checked. I unchecked the box and presto! It started working as expected. Hope this helps someone.