Last post May 03, 2019 03:35 PM by bruce (sqlwork.com)
May 02, 2019 03:30 PM|Navi0113|LINK
Trying to host my first website (ASP.NET Core 2.2 ) on IIS 8.5...relies on Windows Authentication.
The site works fine on Server where it is hosted (automatically takes the name of currently logged user).
But on client machine (part of the domain), it returns 401.2.5.0 with "Domain\TestUser". However, when I login with administrative privileges on the client machine, the site again works fine. I don't know what I am doing wrong here.
Tried with MS IE and MS Edge on client machine, added the website to Intranet zone, turned ON Windows Authentication in Advance tab of IE.
The site has its own Application Pool (let's call it MySitePool). The folder in which site is hosted (C:\inetput\MySite1) has all necessary permissions (Modify-level access to IUSR and MySitePool).
Here is web.config file:
<?xml version="1.0" encoding="utf-8"?>
<location path="." inheritInChildApplications="false">
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
<aspNetCore forwardWindowsAuthToken="true" processPath=".\MySite.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
Using this in ConfigureServices method:
Also, I access the currently logged in user via User.Identity.Name in Razor pages.
There are some observations when I try to access the website from client PC (on same domain as IIS)...
1) Trying to access site from Google Chrome, it asks for username (Domain\TestUser1) and password and then it works. Same with Mozilla Firefox.
2) Trying to access from IE or MS Edge, it keeps on asking for user name password (thrice) and then returns error...invalid credentials.
3) When trying to access from IE / Edge, using admin credentials (via "Use other account" option), it works.
4) When I use IE in Admin mode (Run as Administrator) and use standard-user credentials (TestUser1), it works.
May 03, 2019 03:35 PM|bruce (sqlwork.com)|LINK
this is all about IE configuration for windows identity support. be sure IE see your site as an internet site, and the feature is enabled. just google for troubleshooting.