ASP.NET MVC: Controller.HandleUnknownAction 404 or 405?
问题 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. 回答1: 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 public class HttpPostFilterAttribute