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
精彩评论