How can I create a custom route constraint that will only match AJAX requests?
In a controller I can use Request.IsAjaxRequest().
How can I access IsAjaxRequest from my custom constraint? I've implemented the IRouteConstraint interface and the Match() method as follows:
public class IsAjaxConstraint : IRouteConstraint
{
public bool Match(HttpContextBase httpContext,
Route route,
string parameterName,
RouteValueDictionary values,
RouteDirection routeDirection)
{
// How can I check for an Ajax request here?
}
}