find a location for property in a new city

Friday, 1 October 2010

ASP.NET MVC IsAjaxRequest() not recognising request from jQuery $.ajax()

If you are finding that an AJAX request from, say, a piece of jQuery AJAX code such as $.ajax() $.get() or $.post() or you own custom AJAX code (you legend) is not registering as an AJAX request when using the IsAjaxRequest() then the problem is probably to do with X-Requested-With.

I used .NET Reflector to have a look at how IsAjaxRequest() works and it is something like this:
return ((request["X-Requested-With"] == "XMLHttpRequest") || ((request.Headers != null) && (request.Headers["X-Requested-With"] == "XMLHttpRequest")));

So that means you need to have a header of "X-Requested-With" set to "XMLHttpRequest" which is usually the case when you are using AJAX libraries like ASP.NET's or jQuery's. You can see if this is the case using Fiddler.

However, interestingly you can also set this as either part of your form POST or even a GET querystring! Such as (case sensitive). This will also make IsAjaxRequest() return true.

Follow britishdev on Twitter


  1. Try also data room software and you will see that it helps you to save time and money!

  2. Now I am ready to do my breakfast, when having my breakfast coming again to read further news.
    Top seo blog

  3. I like your blog i read this blog so i am impressed and please next update your content i wait for next update this blog .and i daily follow this site
    Best vpn

  4. All right this YouTube video is much improved than last one, this one has fastidious picture feature as well as audio.

    Best website developer Company in Kanpur

  5. Really appreciated the information and please keep sharing, I would like to share some information regarding online training.Maxmunus Solutions is providing the best quality of this JBOSS Technology And this online training will be very convenient for the learner.And the training will be online and very convenient for the learner.

    For Joining online training batches please feel free to call or email us.
    Email :
    Contact No.-+91-9066638196/91-9738075708

  6. I am curious to find out what blog system you’re using?

    Best web development software Company in Kanpur

  7. really the information is in article is very awesome...
    Software development company in kanpur

  8. This is extremely useful post and enlightening There is no uncertainty about it. I discovered this one really decent and it ought to go into my accumulation. Visit Websites It helped me from numerous points of view.


  9. شركة اصباغ الكويت اصباغ الكويت
    شراء اثاث مستعمل الكويت شركة شراء اثاث مستعمل الكويت
    فني كهربائي منازل الكويت كهربائي منازل بالكويت
    شركة مكافحة البق الكويت افضل شركة مكافحة البق الكويت
    شركة مكافحة حشرات الكويت افضل شركة مكافحة الحشرات الكويت
    نقل عفش مبارك الكبير شركة نقل عفش مبارك الكبير

  10. i am browsing this website dailly , and get nice facts from here all the time .

  11. Excellent read, Positive site, where did u come up with the information on this posting? I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work,If anyone interested similar one's have a look here thanks.

    shih tzu puppies for sale near me
    buy puppy online