Note that there are some explanatory texts on larger screens.

plurals
  1. PORequest.IsAjaxRequest not working properly in asp.net mvc2
    text
    copied!<p>i m using asp.net mvc2 for my application. i have an ajax request sent using jquery. </p> <pre><code>$.ajax{( url:'/home/index' type:'post', data:$('#myform').serialize(), dataType:'html', success:function(response) { //update relevent document portion } }); </code></pre> <p>here is my controller method</p> <pre><code>public ActionResult index(Book book) { Repository _repo = new Repository(); _repo.Add(book); _repo.Save(); if(Request.IsAjaxRequest()) { return RedirectToAction("List",new{id=book.id}); } //do something else } public ActionResult List(int id) { if(Request.IsAjaxRequest())/* here it always returns false even though its been redirected from an ajax request to get here*/ { //do something } } </code></pre> <p>in index actionresult Request.IsAjaxRequest() works properly but when its redirected to List actionresult it does not identify it as ajax request. how can i know that list is being called from an ajax redirection?<br/> <strong>Edit1:</strong> Request.IsAjaxRequest is returning true in IE for both index and List methods while in firefox Request.IsAjaxRequest is true only for index method. when i inspect the code for ajax request i could see two of them; first is post to index method and 2nd is Get from List method. IE sends x-requested-with header with both requests while firefox is sending this header only for first request destined to index method. how can i make firefox work like IE (in this scenario only) i.e sending x-requested-with header with both request in case when second request is not originated from client but is a redirection from first request.<br/> thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload