In my ASP.NET MVC 3 application, I have an action that is triggered through a jQuery AJAX POST request. In this action, I check some DB data with the attributes, and if it passes the validation, I return a PartialView result that is set inside a div on the view in the success callback of the jQuery request. What I want to do is, if it does not pass validation, fully redirect the user to another page in my application.
I know I could do this through Javascript by passing a value to the view, and doing an extra check there, but I would like to know if it can be done on server-side.
In your contorller action you could return either a
PartialViewor aJsonResultpointing to the controller action to redirect to:and then inside the success callback of your AJAX call test in which case you are and take respective steps: