我正在使用我的 Asp.net应用程序托管WCF Rest服务,并且启用了asp.net兼容模式,它工作正常 当我从visual studio运行应用程序但是当我在IIS7中时,我在访问End Point时收到错误说“已经添加了具有
当我从visual studio运行应用程序但是当我在IIS7中时,我在访问End Point时收到错误说“已经添加了具有相同密钥的项目”.
我的服务代码是.
[ServiceContract]
[AspNetCompatibilityRequirements
(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class RestService
{
[OperationContract]
[WebGet(UriTemplate = "Site/{Id}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
public Site GetSite(string Id)
{
return new Site(1);
}
}
和全球ASCX是
protected void Application_Start ()
{
RouteTable.Routes.Add(new ServiceRoute("Rest", new WebServiceHostFactory(), typeof(RestService)));
}
和web.config
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
注意在VS2010模式下每个工作正常但在托管IIS 7时出错
并访问http://example.com/rest/site/2
有什么建议吗?
