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.
I’m overriding ASP.NET MVC’s Controller.HandleUnknownAction(string actionName) method. It’s being called when an action is
Share
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.