Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responding to REQUEST_METHOD = HEAD using ASP.NET MVC

Tags:

asp.net-mvc

I have an ASP.NET MVC site and ELMAH is showing me that my site is erroring when receiving an HTTP request with REQUEST_METHOD = HEAD.

How do I respond to these requests using ASP.NET MVC?

like image 616
Kevin Pang Avatar asked Mar 01 '10 16:03

Kevin Pang


1 Answers

Use the [AcceptVerbs( HttpVerbs.Head )] attribute to mark the method as responding to a HEAD request. You can add more potential methods by OR'ing the verbs together so it can respond to multiple request verbs. I suspect your method is already marked with the attribute as I think it should respond to any request verb if you don't have any restrictions. On a side note, I think it would be pretty rare to get a HEAD request, care to elaborate on why and how you're receiving it?

like image 183
tvanfosson Avatar answered Oct 07 '22 00:10

tvanfosson