【问题标题】:Difference between UriTemplate parameters and method parametersUriTemplate 参数和方法参数的区别
【发布时间】:2014-06-05 07:24:15
【问题描述】:

考虑代码

[WebInvoke(UriTemplate="/{memId}/{username}")]
[ServiceContract]
void Method(string strMemId,string strUname)
{
// my code goes here
}

UriTemplate 中的参数是否与方法参数相同? 如果没有,什么时候需要/需要它们?

谢谢。 任何意见表示赞赏。

【问题讨论】:

    标签: c# wcf c#-4.0 uritemplate


    【解决方案1】:

    如果方法参数是通过Uri传递的,传递的顺序,必须设置Uritemplate。你的情况是(UriTemplate = "/ {strMemId} / {strUname}" ) 如果不这样做,程序将不知道在哪里可以找到所需的参数

    【讨论】:

    • 那么,将 webHttpBinding 作为我们的主要绑定机制时,是否需要 UriTemplate?
    • 不仅有这个绑定。这是一个代表 URI 的模板
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-04
    • 2010-09-14
    相关资源
    最近更新 更多