How can I have MVC 6 return 405 Method Not Allowed instead of 404 Not Found?

孤街醉人 提交于 2019-12-10 18:45:43

问题


It appears that MVC 6 does not return 405 Method Not Allowed responses when a route matches except for the verb. This is, in my opinion, a regression from Web API 2 because it's not as RESTful. Is there an easy way to change this behavior?


回答1:


This is not possible with MVC 6's current implementation. A sad oversight, and one that, along with other abstraction failures on Microsoft's part, drove my team and I to use NancyFx.

https://github.com/aspnet/Mvc/issues/388



来源:https://stackoverflow.com/questions/39856774/how-can-i-have-mvc-6-return-405-method-not-allowed-instead-of-404-not-found

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