开发者

Getting url from area + controller + action programmatically

I have a custom login-actionfilter where that I'm trying to "upgrade" to mvc 2 that uses areas.

private void RedirectToRoute(ActionExecutingContext context, object routeValues)
    {
        var rc = new RequestContext(context.HttpContext, context.RouteData);

        string url = RouteTable.Routes.GetVirtualPath(rc,
            new RouteValueDictionary(routeValues)).VirtualPath;

        context.HttpContext.Response.Redirect(url, true);
    }

That's how it looked in my mvc 1.0 project, I try to call it like this now:

  RedirectToRoute(filterContext,
                    new
                    {
                        controller = Controller,
                        action = Action,
                        area = Area
                    });

What's needed to add to make it redirect to the proper 开发者_JAVA技巧area aswell?

/M


Issue resolved...... I had 2 areas, and it matched the latter one in the 2nd ones MapRoute

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜