web-dev-qa-db-fra.com

L'authentification Windows ne fonctionne pas dans IIS Express, débogage avec Visual studio 2013, Windows 8

Je viens de mettre à niveau mon application de Visual studio 2012 vers Visual studio 2013. Mon authentification Windows ne fonctionne plus. Cela me donne une erreur en dessous.

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

Dans Visual Studio, il est possible de sélectionner l'authentification à partir des propriétés du site Web lui-même. J'ai donc désactivé l'accès anonyme et activé l'authentification Windows, mais il me demande le nom d'utilisateur et le mot de passe comme ci-dessous. Même si je donne des informations d'identification de domaine ici. Son me donne encore et encore ce popup.

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>

Faites-moi savoir si vous souhaitez plus de détails à ce sujet.

Mise à jour:

J'ai découvert que si je supprimais la ligne ci-dessous de web.config, cela commencerait à fonctionner.

     <remove users="*" roles="" verbs="" />
15
Hiren

Soyez prudent avec les modifications de applicationhost.config - dans Visual Studio 2015, j'ai trouvé qu'il parfois réside dans le répertoire local du projet.

Par exemple:

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

Si vous ne savez pas quel fichier de configuration d'application hôte est utilisé, vous pouvez surveiller l'accès aux fichiers avec ProcMon, puis affiner les résultats en fonction de "Chemin" pour voir ce que VS lit réellement au moment du débogage.

pdate: Cela semble également être le comportement dans Visual Studio 2017.

17
Coruscate5

Il semble que vous ayez résolu votre propre question! Bien sur vous. En plus de cet article qui m'aidait, j'ai trouvé que les éléments suivants étaient SUPER utiles pour configurer mon IIS Express.

Authentification Windows IIS Express

Edit: j'ai copié les informations importantes du lien associé au cas où il mourrait. C'est complètement de l'utilisateur vikomall

option-1 :

éditer \My Documents\IISExpress\config\applicationhost.config fichier et activer windowsAuthentication, c'est-à-dire:

<system.webServer>
...
  <security>
...
    <authentication>
      <windowsAuthentication enabled="true" />
    </authentication>
...
  </security>
...
</system.webServer>

option-2 :

Déverrouillez la section windowsAuthentication dans\Mes documents\IISExpress\config\applicationhost.config comme suit

<add name="WindowsAuthenticationModule" lockItem="false" />

Modifier les paramètres de remplacement pour les types d'authentification requis sur "Autoriser"

<sectionGroup name="security">
    ...
    <sectionGroup name="system.webServer">
        ...
        <sectionGroup name="authentication">
            <section name="anonymousAuthentication" overrideModeDefault="Allow" />
            ...
            <section name="windowsAuthentication" overrideModeDefault="Allow" />
    </sectionGroup>
</sectionGroup>

Ajouter le suivant dans le web.config de l'application

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
      <security>
        <authentication>
          <windowsAuthentication enabled="true" />
        </authentication>
      </security>
    </system.webServer>
</configuration>

Le lien ci-dessous peut aider: http://learn.iis.net/page.aspx/376/delegating-configuration-to-webconfig-files/

Après l'installation de VS 2010 SP1, l'application de l'option 1 + 2 peut être requise pour que l'authentification Windows fonctionne. En outre, vous devrez peut-être définir l'authentification anonyme sur false dans IIS Express applicationhost.config:

<authentication>

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

Dans Visual Studio 2017, projet principal asp.net, l'authentification est configurée sur launchSettings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:54491/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "api/values",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "TestAspNetCoreProd": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "api/values",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:54492"
    }
  }
}
4
Huan Jiang