解决方法
两种方式“脱离我的头脑”:
1 – 自定义操作过滤器,如果用户已登录,则会从页面重定向用户.
public class RedirectAuthenticatedRequests : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { if(filterContext.HttpContext.Request.IsAuthenticated) { filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary(new { controller = "SomeController",action = "SomeAction" } )); } base.OnActionExecuting(filterContext); } }
if(Request.IsAuthenticated) return RedirectToAction("SomeOtherView");