当满足某些条件时,我想在控制器中注销。
我的想法是重定向到"/Identity/Account/Logout“
我试过但不起作用
return RedirectToAction("Logout", "Account");普通代码是:
public IActionResult Home_Index()
{
var Crm_Account_Data = _context.Crm_Account.Where(x => x.Crm_Email.Equals(User.Identity.Name)).FirstOrDefault();
if (Crm_Account_Data != null)
{
return View();
}
else
{
// Logout
// return RedirectToAction("Logout", "Account");
}
}发布于 2021-06-12 02:13:03
我建议创建两个操作方法。Login()和Logout()您的登录操作如下所示:
[HttpPost]
public ActionResult Login()
{
if (!IsValidUser)
{
//redirect to login view
}
if (IsValidUser)
{
//executables (perhaps passing a model)
}
return this.RedirectToAction("Index", "Home");
}https://stackoverflow.com/questions/67930271
复制相似问题