开发者

How to redirect route outside of a ASP.NET MVC3 controller in custom attribute?

I want to know how to redirect to a particular route from outside the controller. I have a custom attribute that I need to redirect the route in.

public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
{
    // Want to redirect to route here.

    base.OnAuthorization(开发者_如何学PythonfilterContext);
}


this should work

public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
    {
        // Want to redirect to route here.
        filterContext.Result = new RedirectToRouteResult("routename", routeValues)

        base.OnAuthorization(filterContext);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜