2 回答

TA贡献1821条经验 获得超4个赞
将此代码添加到您的启动以处理访问请求:
services.ConfigureApplicationCookie(options => { options.AccessDeniedPath = "/Account/Access-Denied"; options.LoginPath = "/Account/Login"; options.LogoutPath = "/Account/Signout"; options.SlidingExpiration = true; });
具体来说.AccessDeniedPath
,应该通过将其附加到 Encrypt 视图来缓解您的问题...

TA贡献1909条经验 获得超7个赞
我找到了部分解决方案。
像这样进行配置:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
...
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}");
});
}
和这样的家庭控制器:
public IActionResult Index()
{
if (User.Identity.IsAuthenticated & !HttpContext.Session.Keys.Contains("Key"))
{
HttpContext.Session.SetInt32("Key", 1);
return RedirectToAction("Index", "Encrypt");
}
else
return View();
}
但它在会话期间仅工作 1 次,因此第二次工作需要通过关闭浏览器再次启动会话。
所以还是不好。
如果我总是在获得授权的情况下从主页重定向 - 他将永远不会看到主页。太不好了。
- 2 回答
- 0 关注
- 103 浏览
添加回答
举报