I am using a partial view for login and would like to redirect the user to a new page on success and show the validation errors in the partial view if the model is invalid. The ajax target is being updated and success or failure. If the the model is valid, it is showing the entire new page in the update target but I want it to redirect to the new page. I have tried Redirect and RedirecttoAction but it is not getting the desire results. Any ideas on what I can to go get an ajax update to redirect to a new page, not update the target. Also, let me know if I am using the wrong approach.
Partial View Code:
<% using (Ajax.BeginForm(
"LogOn",
null,
new AjaxOptions {
HttpMethod = "POST",
UpdateTargetId = "SignInForm"
},
new {
id = "SignInForm", ReturnUrl = Request.QueryString["ReturnUrl"]
})) { %>
<<Page HTML Controls>>
<input type="submit" value="Log On" />
<% } %>
Here is the relevant controller code:
public ActionResult Logon(LogOnModel model,string returnUrl)
{
if (ModelState.IsValid)
{
//Login Logic Code
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "App");
}
}
// If we got this far, something failed, redisplay form
if (Request.IsAjaxRequest())
return PartialView("LogOnControl");
return View(model);
}