I need to disable POST, PUT and DELETE verbs on my controllers. I'm currently returning a MethodNotAllowed as shown below but I feel there must be a better way. I suspect there is a filter I can add to the web api pipeline but I'm not sure what I need or where to do it.
public HttpResponseMessage Post([FromBody]string value)
{
return new HttpResponseMessage(HttpStatusCode.MethodNotAllowed);
}
How do I block certain verbs without placing code to return a HttpResponseMessage for each disallowed method in a controller? Nice to have, still return the appropriate http status code.