修改BUG:修改网页未找到时,Error页面重定向错误

This commit is contained in:
Argo-MacBookPro 2018-10-12 18:52:28 +08:00
parent 23d72f4120
commit 83071c9874
2 changed files with 4 additions and 2 deletions

View File

@ -28,7 +28,8 @@ namespace Bootstrap.Admin.Controllers
[AllowAnonymous]
public IActionResult Error(int id)
{
ViewBag.ReturnUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].ToString() ?? Url.Content("~/Home/Index");
var returnUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].ToString();
ViewBag.ReturnUrl = string.IsNullOrEmpty(returnUrl) ? Url.Content("~/Home/Index") : returnUrl;
return id == 404 ? View("NotFound") : View();
}
}

View File

@ -28,7 +28,8 @@ namespace Bootstrap.Client.Controllers
[AllowAnonymous]
public IActionResult Error(int id)
{
var uriBuilder = new UriBuilder(ConfigurationManager.AppSettings["AuthHost"]) { Path = Request.Path, Query = QueryString.Create(CookieAuthenticationDefaults.ReturnUrlParameter, $"{Request.Scheme}://{Request.Host}{Request.PathBase}").ToString() };
var uriBuilder = new UriBuilder(ConfigurationManager.AppSettings["AuthHost"]) { Query = QueryString.Create(CookieAuthenticationDefaults.ReturnUrlParameter, $"{Request.Scheme}://{Request.Host}{Request.PathBase}").ToString() };
uriBuilder.Path += Request.Path;
return Redirect(uriBuilder.ToString());
}
}