In normal AccountControllerMVC3 in my application, if installed returnUrl(in my case, I install it manually), it calls Redirect(returnUrl).
Suppose my return URL is /Admin/HealthCheck(actually this). When I debug, I get the URL, for example http://localhost:3279/Admin/HealthCheck, from a redirect call.
Then I deployed the application to http://localhost/Test. In this case, it Redirect(returnUrl)redirects me to http://localhost/Admin/HealthCheck, rather than to the expected http://localhost/Test/Admin/HealthCheck.
What's going on here? How to fix it (if it is fixed)?
The following is a snippet from the (standard) MVC3 AccountController; you can see where I get the return URL from the query string (for example http://localhost/Test/LogOn?ReturnUrl=/Admin/HealthCheck, albeit an encoded URL).
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
returnUrl = Request.Params["ReturnUrl"];
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}