Share via


RedirectToAction method not working on ajax call

Question

Monday, December 29, 2014 9:54 AM

I have a page where on click of "Save" a jQuery function is called. The function contains an ajax call to an Action method of a controller.(Ex:

$.ajax({ url:"@Url.Action(",})

Till this the functionality works fine. But in the Action method, I have a RedirectToAction("Action", "Controller"). I am not able to redirect to the action method mentioned in the "RedirectToAction".

 

Any help would be appreciated.

Regards,

Saravanan

 

All replies (2)

Monday, December 29, 2014 10:08 AM âś…Answered

for redirecting in Ajax return Json with the location parameter .

Like here:

http://msprogrammer.serviciipeweb.ro/2013/01/21/redirect-and-ajax-redirect-in-mvc/


Monday, December 29, 2014 10:03 AM

It probably does call the RedirectToAction, but you do not have a regular request in process, so it will not respond in the normal way.  Remember that all of this activity is being performed on an asynchronous request that will send the response back to the client in some form of response made of either XML or JSON.