Skip to content

Instantly share code, notes, and snippets.

@emiaj
Created January 23, 2013 19:43
Show Gist options
  • Select an option

  • Save emiaj/4612092 to your computer and use it in GitHub Desktop.

Select an option

Save emiaj/4612092 to your computer and use it in GitHub Desktop.
public static class RequestDataHelper
{
[MarkedForTermination("Use FubuMVC.Core.AjaxExtensions.IsAjaxRequest when updating FubuMVC.Core to latest or kill this when support for IE7 gets dropped.")]
public static bool IsAjaxRequest(IRequestData requestData)
{
var result = false;
requestData.Value(AjaxExtensions.XRequestedWithHeader, delegate(BindingValue value)
{
result = value.RawValue.isAjaxRequest();
});
if(!result)
{
requestData.Value(AjaxExtensions.XRequestedWithHeader.ToLowerInvariant(), delegate(BindingValue value)
{
result = value.RawValue.isAjaxRequest();
});
}
return result;
}
private static bool isAjaxRequest(this object value)
{
return AjaxExtensions.XmlHttpRequestValue.Equals(value as string, StringComparison.InvariantCultureIgnoreCase);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment