简体   繁体   English

在ServiceStack(C#)中使用可变占位符获取路由

[英]Get Route with Variable Placeholder in ServiceStack (C#)

Good Morning, 早上好,

I am attempting to get the original ServiceStack route meaning I want the route with the variable place holder not just the replaced route. 我正在尝试获取原始的ServiceStack路由,这意味着我希望具有可变占位符的路由而不仅仅是替换的路由。 Please see the examples below for more details 请参阅以下示例以了解更多详细信息


Route with variable 可变路线
/foo/{Name} / foo / {名称}

However as part of the request filter I am only able to see 但是,作为请求过滤器的一部分,我只能看到
/foo/JDoe / foo / JDoe

is it possible to capture the italicized text as well as the replaced value? 是否可以捕获斜体文本和替换值? storing and capturing the route with the variable placeholder will be useful for turning routing on/off by route as well as, allowing us to also do a comparison on the expected route with the value that gets replaced visually as well. 使用可变的占位符存储和捕获路由对于按路由打开/关闭路由也非常有用,并且使我们也可以对预期的路由进行比较,并用视觉上替换的值进行比较。 I am using C# and ServiceStack version="3.9.71" targetFramework="net40" in this project. 我在此项目中使用C#和ServiceStack version =“ 3.9.71” targetFramework =“ net40”。 Thanks... Please let me know if you need more details or anything is unclear. 谢谢...如果您需要更多详细信息或不清楚的地方,请告诉我。

~ Mark 〜马克

This feature was added in ServiceStack v4 where you can get the matching route definition with: 此功能已添加到ServiceStack v4中,您可以在其中通过以下方式获取匹配的路由定义:

var route = base.Request.GetRoute();
route.Path.Print(); //= /foo/{Name}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM