簡體   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