Web API 2 routing attributes work in one controller but not another

荒凉一梦 提交于 2019-12-06 01:35:08
Jeff Guillaume

This was simpler than it seemed, but determining why was made more difficult by poor debugging (which was filed and verified as a bug in Codeplex by Kiran Challa. This should be fixed as of Web API 2.1.

I had a controller with this route:

/api/locations/keyword

Which would do a keyword search on keyword.

I had another controller with these routes:

/api/locations/specialties
/api/locations/specialties/123
/api/locations/specialties/keyword

The API engine was confused, because I had two controllers with essentially the same route. I removed one and the problem was fixed.

According to the Codeplex issue tracker, the issue was verified, closed and a new error message was added in Web API 2.1.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!