RedirectToAction not working after successful jquery ajax post? [duplicate]

You cannot redirect from an AJAX post. You could return the URL you want to redirect the browser to however and redirect from Javascript. Controller [HttpPost] public ActionResult GoHome() { return Json(Url.Action(“Index”, “Home”)); } Javascript $.ajax({ type: “POST”, url: “http://localhost/UserAccount/GoHome”, dataType: ‘json’, crossDomain: true, success: function (data) { window.location.href = data; } });

jQuery add CSRF token to all $.post() requests’ data

From Laravel documentation: You could, for example, store the token in a “meta” tag: Once you have created the meta tag, you can instruct a library like jQuery to add the token to all request headers. This provides simple, convenient CSRF protection for your AJAX based applications: $.ajaxSetup({ headers: { ‘X-CSRF-TOKEN’: $(‘meta[name=”csrf-token”]’).attr(‘content’) } }); So … Read more