【发布时间】:2014-10-17 11:35:45
【问题描述】:
我创建了一个 Web 服务,并且正在使用 basicHttpBinding,但问题是当我将 clientCredentialType 设置为 None 时,我可以访问该服务,但如果我设置为 Basic/Windows,我会收到类似“运行时错误”的错误。在 IIS 中使用基本身份验证。我需要 basicHttpbinding 的安全性。如何解决此问题。
Web.Config 中的代码:
<services>
<service name="HealthCareService" behaviorConfiguration="Behavior_Service1">
<endpoint address="" contract="IHealthCareService" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding1" />
<endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding1">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Behavior_Service1">
<serviceThrottling maxConcurrentSessions="10000"/>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
错误屏幕截图:
【问题讨论】:
-
首先,按照错误页面的提示进行操作并设置
。这将显示基本异常和堆栈跟踪。获取并发布它们。 -
@simonatrcl 500 - 内部服务器错误。您要查找的资源有问题,无法显示。在自定义模式设置为关闭后显示
-
@my1 - 查看事件查看器,看看那里是否记录了任何内容。您的服务很可能会引发未处理的异常。
-
向我们展示您的网址,同时告诉我们您如何托管服务?是 IIS 吗? IIS快递?还是自托管?还要显示您的完整 web.config,因为我看不到您的基地址或服务激活。最后,您使用的是哪个 .net 框架版本?
-
@Roman 当我将 clientCredentialType 设置为 basic 但在 IIS 中启用了基本身份验证时,我收到此错误。当我将 clientCredentialType 设置为 None 时,我可以访问该服务。