I am moving some code to a Web API, and I want to only accept requests that are perfect (postdata in order, all headers in order, etc.), and deny other requests. Right now I have it so that if a perfect requests comes in then it returns the correct output with a 200 OK status code, and if a malformed requests comes in (aka a not properly spoofed request) then it returns a 404 NOT FOUND.
The functions in my controller all have a parameter with the FromBody attribute, so that means it works fine if the request uses the content-type "application/json", but when a requests comes in with another content type then it automatically returns a 415 Unsupported Media Type status code. What I want is to basically "hide" all my endpoints and only return something other than a 404 status code when the request is perfect. So I want to change the returned 415 Unsupported Media Type status code with a 404 status code.