ASP.NET路由-末尾带有斜杠
|
考虑以下服务合同:
[WebGet(UriTemplate = \"/stores\")]
DTO.Stores GetAllStores();
[WebGet(UriTemplate = \"/stores/{name}\")]
DTO.Stores GetStores(string name);
我可以到达以下两个网址:http:// localhost / v1 / stores和http:// localhost / v1 / stores / Joe。但是,URL http:// localhost / v1 / stores /(注意末尾的斜杠)向我返回一个“找不到端点”错误。理想情况下,我希望http:// localhost / v1 / stores /调用GetAllStores()。
我怎样才能做到这一点?谢谢!
没有找到相关结果
已邀请:
2 个回复
渐首洽陈染
蕉衫
而且,由于两种方法都返回相同的内容(DTO.Stores),因此可以使用一种方法而不是两种方法来获取Stores(就像现在所做的那样)。像这样:
附注:我不确定这是否可以与WCF一起使用,但请尝试一下。 ;-)