也许我不明白如何正确使用UriTemplate
我总是想搜索传入的网址
api/whatever // that is it
如果 URL 如下所示,我只想得到 api/CheckMainVerified
所以我想如果不使用 UriTemplate,我想子字符串检查或正则表达式会起作用吗?
http://localhost:29001/api/CheckMainVerified/223128
这就是我正在做的
var url = "http://localhost:29001/api/CheckMainVerified/223128";
//var host = new Uri(serverHost.AbsoluteUri);
var host = new Uri("http://localhost:29001");
var apiTemplate = new UriTemplate("{api}/{*params}", true);
var match = apiTemplate.Match(host, new Uri(url));
var finalSearch = match.BoundVariables["api"];
string parameters = match.BoundVariables["params"];
finalSearch.Dump();
parameters.Dump();
match.Dump();