I'm overriding ASP.NET MVC's Controller.HandleUnknownAction(string actionName) method. It's being called when an action is not found and also when an HTTP method is not allowed. How can I distinguish between the two? I'd like to return a 404 when and action is not found and 405 when a method is note allowed.
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- Design RESTful service with multiple ids
- Axios OPTIONS instead of POST Request. Express Res
- Plain (non-HTML) error pages in REST api
- Laravel 5.1 MethodNotAllowedHttpException on store
相关文章
- 我用scrapy写了一个蛮简单的爬虫怎么封装成一个api啊
- 后端给前端的API接口是怎么用代码写的
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Convert C# Object to Json Object
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
The simplest way I can think of is to create custom action filter. This will allow you to return http status code result if method is not allowed
Or better, create more generic version of it, much like AcceptVerbsAttribute
And use it like
Customizing attribute to take HttpVerbs as parameter is up to you.