ASP.Net MVC Toggling IsAjaxRequest property based on file upload?

Posted by Jon on Stack Overflow See other posts from Stack Overflow or by Jon
Published on 2009-06-16T14:53:55Z Indexed on 2010/04/18 20:03 UTC
Read the original article Hit count: 392

Filed under:
|

I have a form all setup to upload a file and that is working fine. However the way my form is submitted is through AJAX. The button that submits is still a type="submit" in case JS is off.

When I save my form the controller determines whether the IsAjaxRequest is true and if so returns some JSON otherwise it does a RedirectToAction.

When I don't specify a filepath in my input type="file" it considers IsAjaxRequest as true. If there is a filepath set then it thinks that IsAjaxRequest is false. How is it determining that?

My other problem is that when it thinks IsAjaxRequest is false and does a RedirectToAction("Index") I don't actually get sent to the Index view.

Thanks

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about jQuery