WCF寄宿与IIS里时遇到:无法满足对安全令牌的请求,因为身份验证失败,解决办法
采用的WSHttpBingding的方式,这种直接通过Ip地址访问服务器的做法会被服务器认为是种不安全的访问,也会报异常说访问被拒绝。
解决办法:
修改服务器配置文件如下:
<system.serviceModel>
<services>
<service behaviorConfiguration=”SpaceBuilder.Blog.Advanced.WCF.AttachmentManageServiceBehavior” name=”SpaceBuilder.Blog.Advanced.WCF.AttachmentManageService”>
<endpoint address=”" binding=”wsHttpBinding” bindingConfiguration=”wsHttpBindingConfiguration”contract=”SpaceBuilder.Blog.Advanced.WCF.IAttachmentManage”>
<identity>
<dns value=”localhost”/>
</identity>
</endpoint>
<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name=”wsHttpBindingConfiguration” maxReceivedMessageSize=”20971510″>
<readerQuotas maxStringContentLength=”20971520″ maxArrayLength=”20971520″/>
<security mode=”None” />
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
这样服务器就不会做安全认证了。