Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Authentication not working in IIS Express, debugging with Visual studio 2013, Windows 8

I just upgraded my application from Visual studio 2012 to Visual studio 2013. My windows authentication is not working any more. It is giving me below error.

     HTTP Error 401.2 - Unauthorized
     You are not authorized to view this page due to invalid authentication headers.

In visual studio there is option to select authentication from website properties itself. So I disabled anonymous access and enable windows authentication but it is asking me for username and password as below popup. Even if I give domain credentials here. Its is still giving me this popup again and again.

enter image description hereenter image description here

Web Config :

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

IIS Express aspnetConfig :

     <authentication>

            <anonymousAuthentication enabled="false" userName="" />

            <basicAuthentication enabled="false" />

            <clientCertificateMappingAuthentication enabled="false" />

            <digestAuthentication enabled="false" />

            <iisClientCertificateMappingAuthentication enabled="false">
            </iisClientCertificateMappingAuthentication>

            <windowsAuthentication enabled="true">
                <providers>
                    <add value="Negotiate" />
                    <add value="NTLM" />
                </providers>
            </windowsAuthentication>

        </authentication>

        <authorization>
            <add accessType="Allow" users="*" />
        </authorization>



        <location path="Path">
        <system.webServer>
        <security>
            <authentication>
                <windowsAuthentication enabled="true" />
                <anonymousAuthentication enabled="false" />
            </authentication>
        </security>
        </system.webServer>
        </location>

Let me know if you want more details on this.

Update :

I found out that if I remove below line from web.config than it start working.

     <remove users="*" roles="" verbs="" />
like image 445
Hiren Avatar asked Jun 12 '14 22:06

Hiren


People also ask

Does IIS Express support Windows authentication?

Unlike IIS Server, IIS Express doesn't support Windows Authentication by default. You can enable the Windows Authentication in IIS Express by modifying the applicationhost. config under the “C:\Users[username]\Documents\IISExpress\config” directory.

How do I enable Windows Authentication in Visual Studio?

Right-click the project in Solution Explorer and select Properties. Select the Debug tab. Clear the checkbox for Enable Anonymous Authentication. Select the checkbox for Enable Windows Authentication.

How do I configure Windows authentication in IIS?

In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services. On the Select Role Services page of the Add Role Services Wizard, select Windows Authentication, and then click Next. On the Confirm Installation Selections page, click Install. On the Results page, click Close.


1 Answers

Be careful with the applicationhost.config modifications - in Visual Studio 2015 I've found that it sometimes resides in the local project directory.

Note: The ".vs" folder is Hidden by default so you may have to select to show "Hidden Items" in Explorer to see it.

For example:

DRIVE:\MYPROJECT\.vs\config\applicationhost.config

If you're not sure which applicationhost config file is being used, you can monitor file access with ProcMon & then narrow down the results based on "Path" to see what VS is actually reading at Debug time.

Update: This appears to be the behavior in Visual Studio 2017 as well.

like image 191
Coruscate5 Avatar answered Sep 21 '22 06:09

Coruscate5