title: HttpContext.Current.Request.IsAjaxRequest() error in MVC 4
body: <p>I am using </p>
  
  <pre><code>HttpContext.Current.Request.IsAjaxRequest() 
  </code></pre>
  
  <p>condition to check for an ajax request in global.asax in Application_Error method but I get the below error:</p>
  
  <blockquote>
    <p>'System.Web.HttpRequest' does not contain a definition for
    'IsAjaxRequest' and the best extension method overload
    'System.Web.Mvc.AjaxRequestExtensions.IsAjaxRequest(System.Web.HttpRequestBase)'
    has some invalid arguments</p>
  </blockquote>
  
  <p>Below is the code:</p>
  
  <pre><code>void Application_Error(object sender, EventArgs e)
      {
  
          Exception exception = Server.GetLastError().GetBaseException();
          HttpException httpException = exception as HttpException;
  
          string ErrorMessage = "";
          ErrorMessage = "Application Level Error";
  
  
          logger.Error(ErrorMessage, exception);
  
          if (System.Web.HttpContext.Current.Request.IsAjaxRequest()) //if its an ajax do not redirect
          {
              return;
          }
      else
      {
        Server.ClearError();
        this.Response.RedirectToRoute("Default", new { controller = "Home", action = "Error" });
      }
    }
  </code></pre>