[英]Failed to map path whem configuring WCF REST service for IIS 7.5
I am having an issue building and deploying WCF Rest services with IIS 7.5.我在使用 IIS 7.5 构建和部署 WCF Rest 服务时遇到问题。 If I open Visual Studio 2010 and create a new project of type "WCF Service Application" and then publish that to IIS it works fine.如果我打开 Visual Studio 2010 并创建一个类型为“WCF 服务应用程序”的新项目,然后将其发布到 IIS 它工作正常。 However, when I try to specify a WebGet Property on the operation contract from the IService.cs interface I get an error.但是,当我尝试从 IService.cs 接口在操作合同上指定 WebGet 属性时,出现错误。
Interface (from IService.cs):接口(来自 IService.cs):
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate = "hello/?n={name}")]
Message SayHello(string name);
}
Corresponding Method (from Service.svc):对应方法(来自Service.svc):
public Message SayHello(string name) {
return Message.CreateMessage(MessageVersion.None, "*", "Hello "+name+"!");
}
I try to publish this to an IIS application I created (http://localhost/rest/) under my root site (http://localhost/) and the publish works successfully, however when I attempt to visit any page from the browser I get the following error:我尝试将其发布到我在根站点 (http://localhost/) 下创建的 IIS 应用程序 (http://localhost/rest/) 并且发布成功,但是当我尝试从浏览器访问任何页面时我收到以下错误:
Failed to map the path '/rest'.
I also tried changing the UriTemplate to [WebGet(UriTemplate = "rest/hello/?n={name}")]
and I get the same error.我还尝试将 UriTemplate 更改为[WebGet(UriTemplate = "rest/hello/?n={name}")]
并且我得到了同样的错误。
I am using the default configuration file from IIS:我使用的是 IIS 中的默认配置文件:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I should also mention that I am using an application pool for .NET 4.0.我还应该提到我正在使用 .NET 4.0 的应用程序池。
Please help as I am very puzzled by this.请帮忙,因为我对此感到非常困惑。
Thanks in advance!提前致谢!
Jeffrey Kevin Pry杰弗里·凯文·普瑞
Since no one seemed to be interested in the question:) I figured it out on my own.因为似乎没有人对这个问题感兴趣:) 我自己想通了。
It seems that I had to do the following to get it working:看来我必须执行以下操作才能使其正常工作:
That did the trick.那成功了。 It is all working now.现在一切正常。 Hopefully I can save someone a few hours or so of Googling.希望我可以为某人节省几个小时左右的谷歌搜索时间。
Thanks,谢谢,
Jeffrey Kevin Pry杰弗里·凯文·普瑞
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.