2021年3月10日星期三

Why does IIS behave differently than Local IIS and IIS Express? (ASP.NET Core + Angular + Windows Authentication)

If I create an ASP.NET Core + Angular project and enable Windows Authentication (following these instructions link) and debug it using IIS Express, why does the Angular app load if I open the browser with a local user (runas /user:MY-PC\local-user Chrome.exe) which is not in AD? Shouldn't IIS Express ask me for credentials?

If I publish to Local IIS (with Windows Authentication enabled and Windows Hosting Bundle installed) using Web Deploy I get the same result, Angular app loads and Local IIS does not ask for credentials. I tried splitting the project with ASP.NET Core API + Angular, but I got the same result. I had to implement an endpoint with some logic to return 401 (not network user), 403 (network user but not in my AD Group) and a Guard in Angular to avoid loading the Component and 401 and 403 pages.

However, when I did publish to IIS on the server (manually, I created the website and copied the files, and installed Windows Hosting Bundle), I realized the behavior is different, the Angular app is not loaded and IIS always asks for credentials. If I put wrong credentials or click on Cancel, IIS shows 401. With the correct credentials I can access and browser will remember them, but if I close and open the browser again, I need to re-enter my credentials, which is a bit annoying.

IIS Express and Local IIS never ask me for credentials when I open a normal browser (using my AD account).

Why does IIS behave differently than Local IIS and IIS Express?

https://stackoverflow.com/questions/66575504/why-does-iis-behave-differently-than-local-iis-and-iis-express-asp-net-core March 11, 2021 at 10:07AM

没有评论:

发表评论