While I realise I can add a generic route (SO Post) to redirect all HEAD requests to a central controller. This is not the end of the story because then I would need to validate that the path matches a controller action and is not a 404 etc. This all adds overhead and seems to me should rather be done inside the actions themselves - see below.
However what I want to do is that if one of my controller methods is hit I would like it to generically return a 200 viz:
public virtual ActionResult SomeActionMethod()
{
if (Request.RequestType == "HEAD")
return new HttpStatusCodeResult(HttpStatusCode.OK);
//Other code here that does things like DB calls etc. etc.
}
So instead of having to add the if test everywhere how do I generically for a HEAD:
- Respond with a HttpStatusCode.OK for all of my action methods
- Optionally turn off 1. when I want to do some additional processing before deciding whether to return HttpStatusCode.OK