我如何才能使MVC 6返回405 Method Not Allowed而不是404 Not Found? [英] How can I have MVC 6 return 405 Method Not Allowed instead of 404 Not Found?
本文介绍了我如何才能使MVC 6返回405 Method Not Allowed而不是404 Not Found?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
似乎一条路线匹配时,除了动词之外,MVC 6都不返回405 Method Not Allowed
响应.在我看来,这是Web API 2的回归,因为它不像RESTful.有没有简单的方法可以改变这种行为?
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?
推荐答案
使用MVC 6的当前实现是不可能的.令人不快的疏忽,再加上Microsoft的其他抽象失败,促使我和我的团队使用 NancyFx .
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
这篇关于我如何才能使MVC 6返回405 Method Not Allowed而不是404 Not Found?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文