Asp.net mvc 5 Windows身份验证MVC-1台IIS_Express服务器,2个应用程序,2个结果

Asp.net mvc 5 Windows身份验证MVC-1台IIS_Express服务器,2个应用程序,2个结果,asp.net-mvc-5,windows-authentication,iis-express,Asp.net Mvc 5,Windows Authentication,Iis Express,大家好 我完全被难住了。我正在使用MS VSExpress 2013 for Web开发一个MVC应用程序,现在我需要添加Windows身份验证。使用向导创建默认MVC应用程序并选择Windows身份验证,它似乎工作正常。让我们调用默认应用程序App1,即我开发的应用程序App2 监视两个应用的Watch中的Context.User对象: App1返回: User {System.Security.Principal.WindowsPrincipal} System.Sec

大家好 我完全被难住了。我正在使用MS VSExpress 2013 for Web开发一个MVC应用程序,现在我需要添加Windows身份验证。使用向导创建默认MVC应用程序并选择Windows身份验证,它似乎工作正常。让我们调用默认应用程序App1,即我开发的应用程序App2

监视两个应用的Watch中的Context.User对象:

App1返回:

    User    {System.Security.Principal.WindowsPrincipal}
    System.Security.Principal.WindowsIdentity
    AuthenticationType  "Negotiate" string
    IsAuthenticated         true    bool
    Name          "MyDomain\\Andrew"    string
使用开发的应用程序时,结果如下:请注意,返回的对象不同(App1=System.Security.Principle.WindowsPrinciple,App2=System.Web.Security.RolePrinciple)

    User    {System.Web.Security.RolePrincipal} 

    Identity    {System.Security.Principal.GenericIdentity} 
    AuthenticationType    ""    string
    IsAuthenticated    false    bool
    Name                  ""    string

    HttpContext.Current.Request.LogonUserIdentity.Name  "MyDomain\\Andrew"
将已开发的app Development Server属性切换为Windows Authentication=Enabled、Anonymous Authentication=Disabled时,结果是立即:

Server Error in "/" Application. 
Resource cannot be found. 
Http 404... 
Requested URL:/Account/Login
我检查并比较了: 两个应用程序的Web.config文件和IISExpress\config\applicationhost.config设置

我的知识有限(基于阅读上面的所有问题以便查找),我猜App2认为它使用的是表单身份验证,而不是Windows身份验证

HttpContext.Current.Request.LogonUserIdentity.Name对象(在上发现此对象)

我补充说:

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

到Web.config…没有乐趣

有人知道为什么这两个应用程序返回不同的用户对象,以及在哪里可以更正吗?为什么App2不能从与App1相同的IISExpress服务器获得IsAuthenticated=true

谢谢

出于某种奇怪的原因(此处编辑是原因->/EDIT,向导生成的app1不需要Web.config中的这两行代码)

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

一切都很好。 还应确保IISExpress服务器配置文件applicationhost.config(在IISExpress安装文件夹中)包含所需的正确条目: 全球进入:

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

System.Security.Principal.WindowsPrincipal
           <windowsAuthentication enabled="true">
                <providers>
                    <add value="Negotiate" />
                    <add value="NTLM" />
                </providers>
            </windowsAuthentication>