【问题标题】:How to set IgnoreTrailingSlash on UriTemplate如何在 UriTemplate 上设置 IgnoreTrailingSlash
【发布时间】:2015-11-27 10:08:40
【问题描述】:

我有用 vb.net 编写的 REST 服务,我有以下 <WebGet>

<WebGet(UriTemplate:="Servers", ResponseFormat:=WebMessageFormat.Xml, BodyStyle:=WebMessageBodyStyle.WrappedResponse)>

所以我希望能够捕获对ServersServers/ 的请求,这样我就可以更改UriTemplate:="Servers/",但我读到了IgnoreTrailingSlash,但我不知道我是如何在我的&lt;WebGet&gt;。我知道它需要在UriTemplate 上设置,但我完全坚持这一点。

【问题讨论】:

    标签: vb.net wcf rest


    【解决方案1】:

    这应该会有所帮助 -

    [WebGet(UriTemplate = "/{key}/")]
    

    这里很好读-

    http://blogs.msdn.com/b/rjacobs/archive/2011/05/23/how-to-handle-the-trailing-slash-in-a-wcf-http-service.aspx

    【讨论】:

    • 谢谢你,是的,我知道将尾随空格添加到 UriTemplate 会产生预期的效果,但我发现这样做我无法读取授权标头(在此处提出: stackoverflow.com/questions/33894869/…)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    • 2012-03-08
    • 1970-01-01
    • 2014-10-18
    • 2013-10-28
    • 1970-01-01
    相关资源
    最近更新 更多