I'm attempting to redirect users after successfully completing a form.
Controller:
public ActionResult Create(Acquisition acquisitions)
{
return Json(new
{
redirectUrl = Url.Action("Index", "Acquisitions"),
isRedirect = true
});
}
After adding the return Json to my controller I'm getting this error message:
Error 6 The type 'System.Web.Routing.RouteValueDictionary' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web, Version=4.0.0.0, Culture=neutral...
JavaScript:
$.ajax({
type: "POST",
url: "/Acquisitions/Create",
data: $("form").serialize(),
success: function (data) {
if (data.isRedirect) {
window.location.href = data.redirectUrl;
}
},
error: function () {
alert("error");
}
});