我想知道如何从控制器外部重定向到特定路由。我有一个自定义属性,我需要重定向路由。
public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
{
// Want to redirect to route here.
base.OnAuthorization(filterContext);
}
答案 0 :(得分:6)
这应该有效
public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
{
// Want to redirect to route here.
filterContext.Result = new RedirectToRouteResult("routename", routeValues)
base.OnAuthorization(filterContext);
}