Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF REST url前缀属性_C#_.net_Wcf_Asp.net Web Api_Wcf Rest - Fatal编程技术网

C# WCF REST url前缀属性

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

我正在开发WCF REST服务。我有一份合同:

[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/”开始。