Using '.' in Web Api using Attribute Routing is giving 404 error
我正在使用"路由属性"尝试通过url将字符串发送到我的Web Api。
我有一条定义为
的路线
1 | [Route("Search/{searchText}")] |
我期望一个字符串值为searchText。似乎工作正常,但如果出现"。",则会出现错误。在我的参数中。
对于前。
1 | http://localhost/api/Person/Search/me is working fine, |
但
1 | http://localhost/api/Person/Search/me.me |
在我的浏览器中抛出404错误。
"。"使用常规路由,字符ir可以正常工作
1 | http://localhost/api/Person?q=me.me |
我得到的错误只是属性路由的情况。
我一直在关注有关所有参考的属性路由的这篇文章-http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2如何使用属性路由发送'。'字符作为字符串的一部分?
尝试在
我用来解决同一问题的线程:[1]:URL中的点导致使用ASP.NET mvc和IIS的404
编辑:如果您需要对多个路径执行此操作,则可能必须对路径执行