繁体   English   中英

配置 WCF REST 服务的 map 路径失败。

[英]Failed to map path whem configuring WCF REST service for IIS 7.5

我在使用 IIS 7.5 构建和部署 WCF Rest 服务时遇到问题。 如果我打开 Visual Studio 2010 并创建一个类型为“WCF 服务应用程序”的新项目,然后将其发布到 IIS 它工作正常。 但是,当我尝试从 IService.cs 接口在操作合同上指定 WebGet 属性时,出现错误。

接口(来自 IService.cs):

[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebGet(UriTemplate = "hello/?n={name}")]
    Message SayHello(string name);
}

对应方法(来自Service.svc):

public Message SayHello(string name) {
   return Message.CreateMessage(MessageVersion.None, "*", "Hello "+name+"!");
}

我尝试将其发布到我在根站点 (http://localhost/) 下创建的 IIS 应用程序 (http://localhost/rest/) 并且发布成功,但是当我尝试从浏览器访问任何页面时我收到以下错误:

Failed to map the path '/rest'.

我还尝试将 UriTemplate 更改为[WebGet(UriTemplate = "rest/hello/?n={name}")]并且我得到了同样的错误。

我使用的是 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>

我还应该提到我正在使用 .NET 4.0 的应用程序池。

请帮忙,因为我对此感到非常困惑。

提前致谢!

杰弗里·凯文·普瑞

因为似乎没有人对这个问题感兴趣:) 我自己想通了。

看来我必须执行以下操作才能使其正常工作:

  1. 打开命令提示符 (cmd.exe)
  2. cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319\(会因设置而异)
  3. 执行 aspnet_regiis.exe -i

那成功了。 现在一切正常。 希望我可以为某人节省几个小时左右的谷歌搜索时间。

谢谢,

杰弗里·凯文·普瑞

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM