2012-06-04 27 views
0

我試圖啓用Windows身份驗證並禁用Intranet應用程序的匿名身份驗證。我已經在IIS7中啓用了Windows身份驗證並禁用了匿名,並將我的Web.Config設置爲使用Windows身份驗證。禁用Web應用程序的匿名身份驗證會導致錯誤

<system.web> 
    <authentication mode="Windows" /> 
    <compilation debug="true" targetFramework="4.0" /> 
</system.web> 

當我部署並運行我的應用程序時,只會加載頁面標題。當我瀏覽到Chrome或IE我的Service.svc文件,我得到以下錯誤:

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

System.NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

我會認爲這是我的web.config或Service.svc.cs一個問題,但我不能識別它。這隻發生在一項服務上。在IIS7中啓用匿名身份驗證將解決該問題,但我需要禁用它。

在我ServiceRefernces.ClientConfig,我有:

<configuration> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IService" maxBufferSize="2147483647" 
       maxReceivedMessageSize="2147483647"> 
       <security mode="None" /> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
    <endpoint address="http://OHARA-WIN7/nightlyweb/Service.svc"  
     binding="basicHttpBinding" 
     bindingConfiguration="BasicHttpBinding_IService"  
     contract="ServiceReference2.IService" 
     name="BasicHttpBinding_IService" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

我已經看到了很多,人們被告知TransportClientCredentialType設置爲NTLM的帖子,但VisualStudio的不承認這個元素。

+0

它不可能與服務有關,但很容易分辨;這是否發生在您網站上的每項服務或只有一項服務? –

+0

只是這項服務。 – zalpha314

+0

即時消息猜測(因此沒有發佈這個答案),但也許它與iis的身份驗證設置有關?你是否也在那裏標記了Windows身份驗證?編輯:我說的話可能是真實的,如果你不工作在集成模式,離開iis和asp.net中的身份驗證處理 – YavgenyP

回答

3

我終於明白了。經過與我的經理項目之一的進一步比較後,我注意到我應該將此代碼添加到我的Web.COnfig,而不是我想要的我的ServiceReferences.ClientConfig。

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding> 
       <security mode="TransportCredentialOnly"> 
        <transport clientCredentialType="Windows" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
</system.serviceModel> 
+0

沒有工作。匿名訪問在發佈後切換到啓用狀態。 – Karlth

相關問題