如何重定向已登录的用户尝试访问登录页面MVC3

Doa*_*ong 3 asp.net-mvc-3 form-authentication

我正在使用MVC3进行表单身份验证.除了一件事,一切都很好.我想在他/她再次尝试访问LogOn页面时将经过身份验证的用户重定向到另一个页面.那我该怎么做呢?

Kai*_*mer 7

在你的LogOn Action中做这样的事情.

if (HttpContext.Request.IsAuthenticated)
{
   return RedirectToAction("Action", "Controller");
}

return View();
Run Code Online (Sandbox Code Playgroud)