简体   繁体   中英

Windows Authentication issue with C# MVC web site

I am using Windows Authentication for the first time in a C# MVC web project and i have run into some issues. If i am accessing the website from localhost, the browser will prompt for windows credentials. This only happens with a new browser session. After that the site is opened. When i try to access the site from a remote machine on the same network the browser does not prompt for credentials and I receive a 403 error. Viewing the page is declined. I created a login page to redirect unauthorized users to. Their credentials will be approved via Active Directory. In order to do this i had to enable Anonymous Authentication in IIS which i thought shouldn't be done when using Windows Authentication instead of Forms. Could some one please help me with the 403 error and best practices/configurations for Windows Authentication? Thanks

This did the trick for me: web.config:

<appSettings>
    <add key="autoFormsAuthentication" value="false" />
    <add key="enableSimpleMembership" value="false" />

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>

<authentication mode="Windows" />
<identity impersonate="false" />
<authorization>
   <deny users="?" />
</authorization>

I did have to keep Anonymous Authentication enabled in IIS which i'm still not sure is correct. Windows Authentication also enabled in IIS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM