Create a route with RouteConstraint as follows:
routes.MapRoute( "HEAD Requests", "{*fullPath}", new { controller = "Head", action = "Index" }, new { fullPath = new MustBeHeadRequest() } ); public class MustBeHeadRequest : IRouteConstraint { public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { return httpContext.Request.HttpMethod.ToLowerInvariant() == "head"; } }
Place the route at or near the top of your routes. When a HEAD request is requested, it will be redirected to the action of the HeadController pointer.
counsellorben
source share