【发布时间】:2020-01-19 13:05:53
【问题描述】:
在我的 ASP.NET MVC5 页面中,我有一个带有超时的个人登录功能。这很好用,一旦超时过期,登录页面会在下一个操作中打开,然后继续。 只有一个布局问题。如果我在 PartialView 中单击已注销的用户,登录页面将在此 PartialView 中呈现,而不是在整个页面上。 验证码:
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
{
if (filterContext.Result == null || filterContext.Result is HttpUnauthorizedResult)
{
filterContext.HttpContext.Session["PlantId"] = filterContext.HttpContext.Request.QueryString["PlantId"];
filterContext.HttpContext.Session["ShowOnlyEnabledRecipes"] = filterContext.HttpContext.Request.QueryString["ShowOnlyEnabledRecipes"];
filterContext.Result = new RedirectResult("~/UserLogin/Login");
}
}
和控制器:
[HttpPost]
public ActionResult Login(LoginModel loginModel)
{
Initialize();
...
return View(loginModel);
}
如何确保登录表单始终占据整个页面?另外,如果它是通过单击 PartialView 来调用的?
【问题讨论】:
标签: asp.net authentication asp.net-mvc-5