Redirect (URL) not working

In the context of ASP.net MVC3, I have this line of code in a controller action that is trying to redirect to a specific URL.

return Redirect(returnUrl);

returnUrl is a string containing "/ Home / Index /". For some reason, the redirection does not occur, and I remain on one screen. I tried to remove the trailing slash, but did not succeed. Any ideas why the redirect is not happening?

+5
source share
2 answers

Redirect URL- URL-. , , :

return RedirectToAction("Index", "Home");

, URL- hardcoding, .

, , AJAX, , = > , , . AJAX HTML- /Home/Index, AJAX.

AJAX , , , JSON, URL-, :

return Json(new { redirectToUrl = Url.Action("Index", "Home") });

window.location.href:

success: function(result) {
    window.location.href = result.redirectToUrl;
}
+13

SAME LOGIN SCREEN , , cookie .

, Redirect RedirectToLocal , :

FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
return RedirectToLocal(returnUrl);

, cookie , , .

+2

All Articles