Pham Ngoc Hai personal web site

Syndicate

ASP.NET MVC3 jQuery form POST and Redirect
 
Written by Pham Ngoc Hai, on 26-11-2011 10:18

It has been some time since I touched ASP and M$ stuff. Today while working with ASP.NET and jQueryMobile, I discovered that my redirection no longer worked.

If you have a form POST to an action that return a Redirect like:

[HttpPost]

public ActionResult Reserve(ReserveViewModel reserveViewModel)

{

....

return Redirect(redirectUrl);

 

ISS will return an HTTP 302 redirection, in order for jQuery to redirect to that URL instead of using AJAX to handle. Your form must have an data-ajax="false", like:

<form action="/Ticket/Reserve" data-ajax="false" method="post">

....

</form> 

That will disable AJAX handling on that form and your browser will happily redirect to the new address. 

Last update: 26-11-2011 10:34

Published in : Computer stuff, Programming
Quote this article in website Favoured Print Send to friend Related articles Save this to del.icio.us

Users' Comments (0) RSS feed comment

No comment posted

Add your comment



mXcomment 1.0.9 © 2007-2012 - visualclinic.fr
License Creative Commons - Some rights reserved
Next >


Search

Calendar

 Jan   February 2012   Mar

SMTWTFS
   1  2  3  4
  5  6  7  8  91011
12131415161718
19202122232425
26272829 
Techies Resources High Level Synthesis

Random Photos






Donate

Enter Amount:

Sponsored Links

Copyright © 2007 Joomla Templates By Joomladesigns.  Modified By Pham Ngoc Hai