I created a simple way of doing things in an ASP.Net MVC 2 project:
public class HomeController : Controller { public ActionResult TestMe() { return View(); } }
Then I ran Fiddler and created an HTTP GET request to click on this URL:
http://localhost.cla1149/Home/TestMe
The expected full page content has been returned.
Then I changed the request to use HTTP HEAD instead of HTTP GET . I received only the expected head information and information about the absence in the source file.
HTTP/1.1 200 OK Server: ASP.NET Development Server/10.0.0.0 Date: Wed, 07 Jul 2010 16:58:55 GMT X-AspNet-Version: 4.0.30319 X-AspNetMvc-Version: 2.0 Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 1120 Connection: Close
I assume that you include an action method restriction, so that it will only respond to HTTP GET . If you do something like this, it will work for both GET and HEAD , or you can completely omit the restriction if it doesn't give a value.
public class HomeController : Controller { [AcceptVerbs(new[] {"GET", "HEAD"})] public ActionResult TestMe() { return View(); } }
a7drew Jul 07 2018-10-10T00: 00-07
source share