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);
}
Run Code Online (Sandbox Code Playgroud)
这应该工作
public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
{
// Want to redirect to route here.
filterContext.Result = new RedirectToRouteResult("routename", routeValues)
base.OnAuthorization(filterContext);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1296 次 |
| 最近记录: |