Die*_*xel 0 c# asp.net asp.net-mvc attributes asp.net-mvc-3
我想知道如何从控制器外部重定向到特定路由.我有一个自定义属性,我需要重定向路由.
public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
{
    // Want to redirect to route here.
    base.OnAuthorization(filterContext);
}
这应该工作
public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
    {
        // Want to redirect to route here.
        filterContext.Result = new RedirectToRouteResult("routename", routeValues)
        base.OnAuthorization(filterContext);
    }
| 归档时间: | 
 | 
| 查看次数: | 1296 次 | 
| 最近记录: |