C# WCF REST url前缀属性
我正在开发WCF REST服务。我有一份合同:C# WCF REST url前缀属性,c#,.net,wcf,asp.net-web-api,wcf-rest,C#,.net,Wcf,Asp.net Web Api,Wcf Rest,我正在开发WCF REST服务。我有一份合同: [ServiceContract] public interface IContract { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "/somem
[ServiceContract]
public interface IContract
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
UriTemplate = "/somemethod/{param1}")]
SomeResult SomeMethod(int param1) { ... }
/*
More methods...
*/
}
是否有一种方法可以为给定契约的所有方法配置公共url前缀。可能是Web API中的类似内容[RoutePrefix(“…”)
属性?试试这样-
UriTemplate = "/users/somemethod/{param1}"
老实说,我不确定这是否可能,但也许从WebInvoke派生您自己的属性会有所帮助?然后,您可以在内部将前缀添加到将要设置的UriTemplate的任何内容中
但我从未尝试过…你说的公共Url前缀是什么意思?@Tommassiov比如,我希望我的所有Url都从“/users/”开始。