【发布时间】:2018-08-09 17:56:23
【问题描述】:
我收到此错误,我无法动摇它。这个问题与this SO 问题类似,还有很多其他问题,更不用说页面本身了。
是的,我完全知道namespace 和service name 必须完全匹配。我现在读了无数次。
我有一个在 IIS 中运行的 WCF 服务库。该服务器是 Windows Server 2016 标准版。我将App.config 重命名为Web.config,尽管我尝试使用App.config。我尝试了每个似乎无数的配置,但仍然是相同的错误。是的,我尝试添加绑定并指定basicHttpBinding。
Web.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="MyTesterLibrary.MyTester" behaviorConfiguration="MetadataBehavior">
<endpoint address="" binding="wsHttpBinding" contract="MyTesterLibrary.IMyTester" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
主类
namespace MyTesterLibrary
{
public class MyTester : IMyTester
{
public string GetVersionInfo()
{
Backup.GetVersionInfo(out string response);
return response;
}
}
}
接口类
namespace MyTesterLibrary
{
[ServiceContract]
public interface IMyTester
{
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/GetVersionInfo")]
[OperationContract]
string GetVersionInfo();
}
}
ProductServiceHost.svc
<%@ ServiceHost Service="MyTesterLibrary.MyTester" %>
我按照另一个站点上的说明创建了 IIS 站点。这张截图说明了一切。
我知道在引用的 SO 文章中,该人坚持认为问题出在 IIS 中,但事实并非如此,但我的问题确实是这样。我刚刚又试了basicHttpBinding,还是一样。
asp.net 论坛上的This question 也很有趣。我本能地将App.config 重命名为Web.config 并重建了DLL。 IIS 不读取“App.config”。
想法?
【问题讨论】:
标签: c# .net wcf iis web-config