繁体   English   中英

为什么我的MVC3网页没有向IIS Express发送Windows凭据?

[英]Why is my MVC3 web page not sending Windows credentials to IIS Express?

我一直在努力让Windows身份验证与我的MVC3应用程序一起开发(VS 2010 SP1),到目前为止还没有真正的运气。 我在我的开发机器上运行XP(直到明年没有钱进行升级),如果这有所不同。 我还应该提到我使用IIS Express作为VS 2010的默认Web开发服务器。

我开始使用一个空的MVC3应用程序,因为我没有从VS菜单中获得Intranet模板,直到我昨天升级了MVC3工具(好吧,我有点慢)。 一旦我安装并检查了该模板,我就将DirectoryServices的引用添加到了我的项目中,并在页面的右上角添加了显示当前登录用户的代码。 根据图形,它现在应该说“欢迎PCE \\ dnewman!”

我遵循了这篇文章中的优秀说明: IIS Express Windows身份验证并确实取得了一些进展。 但是,我现在从IIS Express收到401.2错误,告诉我我没有被授权......

所以,我进入了我的项目属性并将Anonymous Authentication设置为Enabled。 现在我可以访问该网页,但我在页面右上角看到的是“欢迎!” - 没有用户名。

我尝试使用IE和Firefox,结果相同。 什么$#^&! 我在这儿失踪了? 好像我没有登录到Windows !! 我在哪里开始寻找问题?

在几年前的前雇主,我写了一个Windows窗体应用程序,用他们的Windows登录凭据对用户进行身份验证。 在这种情况下,我必须特别注意发送凭据,然后在服务端显式验证它们。 我是否需要做些什么来使浏览器包含每个GET或POST的凭据?

根据请求,这是我的web.config的内容,对所有Glimpse配置的东西道歉。

<?xml version="1.0" 
  encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="glimpse" 
         type="Glimpse.Core.Configuration.GlimpseConfiguration" />
  </configSections>
  <appSettings>
    <add key="ClientValidationEnabled" 
     value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" 
     value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" 
             targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
    <pages>
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <trace writeToDiagnosticsTrace="true" 
       enabled="true" 
       pageOutput="false" />
    <httpModules>
      <add name="Glimpse" 
       type="Glimpse.Core.Module" />
    </httpModules>
    <httpHandlers>
      <add path="glimpse.axd" 
       verb="GET,POST" 
       type="Glimpse.Core.Handler" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <security>
      <authentication>
        <anonymousAuthentication enabled="false"/>
        <windowsAuthentication enabled="true" />
      </authentication>
    </security>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="Glimpse" 
       type="Glimpse.Core.Module,Glimpse.Core" 
       preCondition="integratedMode" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <add name="Glimpse" 
       path="glimpse.axd" 
       verb="GET,POST" 
       type="Glimpse.Core.Handler,Glimpse.Core" 
       preCondition="integratedMode" />
    </handlers>
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IReporting" 
             maxBufferSize="1024000" 
             maxBufferPoolSize="1000000" 
             maxReceivedMessageSize="1024000">
          <readerQuotas maxDepth="200" 
                    maxStringContentLength="65536" 
                    maxArrayLength="32768" 
                    maxBytesPerRead="4096" 
                    maxNameTableCharCount="16384" />
          <security mode="None" />
        </binding>
        <binding name="normalBinding">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint name="tcpAdminServiceEndpoint" 
            address="net.tcp://PCESRV22.pce.local:9000/ProductionMonitor/AdminService" 
            binding="netTcpBinding" 
            bindingConfiguration="normalBinding" 
            contract="Contracts.IAdmin" />
      <endpoint name="tcpMasterDataServiceEndpoint" 
            address="net.tcp://PCESRV22.pce.local:9010/ProductionMonitor/MasterDataService" 
            binding="netTcpBinding" 
            bindingConfiguration="normalBinding" 
            contract="Contracts.IMasterData" />
      <endpoint name="tcpReportingServiceEndpoint" 
            address="net.tcp://PCESRV22.pce.local:9030/ProductionMonitor/ReportingService" 
            binding="netTcpBinding" 
            bindingConfiguration="NetTcpBinding_IReporting" 
            contract="Contracts.IReporting" />
    </client>
  </system.serviceModel>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" 
                      publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" 
                     newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <glimpse enabled="true" />
</configuration>

我非常愿意根据需要透露更多细节,但我真的不知道从哪里开始寻找。 我能找到的每篇文章或文章似乎都认为这部分只是作为Windows / MVC3 / ASP.NET设置的一部分而发生的。

谢谢,戴夫

如果你遵循引用帖子中的所有建议,你最终会得到一个非工作的混乱,就像我做的那样。 每个答案都有自己的优点,但应用所有答案只会以挫败感结束。

回答所有问题并让我工作的Microsoft的帖子在这里: 如何使用ASP.NET MVC创建Intranet站点

保存此链接,这是金色的......

我还发现“Add Deployable Dependencies”选项可以破坏Windows身份验证。 如果我在“添加可部署依赖项”对话框中选择了“带有Razor语法的ASP.NET网页”选项,它会立即破坏Windows身份验证并似乎返回到表单身份验证 - 我收到404错误“资源不能是发现“寻找/帐户/登录。 我没有必要部署它,只是选择该选项打破了它。 解决它的唯一方法是重新开始。 我无法删除任何东西以使其重新开始工作,而我无法确定导致此行为的更改。

这篇博客文章保存了这一天: 如何使用“\\ bin部署”将ASP.NET MVC 3应用程序部署到Web主机 - 它显示了在部署它时不需要使用哪些程序集以及如何将它们包含在Web主机中“添加可部署的依赖关系”废话。

我希望这能节省一些人花费的时间来试图让它全部运转起来。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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