[英]Disabling Anonymous authentication for web application causes error
我正在尝试为Intranet应用程序启用Windows身份验证并禁用匿名身份验证。 我已经启用了Windows身份验证,并在IIS7中禁用了匿名功能,并将Web.Config设置为使用Windows身份验证。
<system.web>
<authentication mode="Windows" />
<compilation debug="true" targetFramework="4.0" />
</system.web>
当我部署并运行应用程序时,将仅加载页面标题。 当我在Chrome或IE中导航到Service.svc文件时,出现以下错误:
此服务的安全设置需要“匿名”身份验证,但是承载此服务的IIS应用程序未启用该身份验证。
System.NotSupportedException:此服务的安全设置需要“匿名”身份验证,但未为承载此服务的IIS应用程序启用它。
我认为这是我的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无法识别此元素。
我终于弄明白了。 与经理的一个项目进行了进一步比较之后,我注意到应该将这段代码添加到Web.COnfig中,而不是像我认为的那样将其添加到ServiceReferences.ClientConfig中。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.