我想知道如何保存
UrlRedirect
在里面
ASP.NET MVC-4
:
例如,我有这样的:
/admin/category/add/81/142
但在我使用这个之后:
return RedirectToAction("Add", "Category", new RouteValueDictionary
{
{"id", siteid.Value},
{"cid", pid.HasValue ? pid.Value : cid.Value }
});
我明白了:
/admin/category/add?id=81&cid=142
但我想要原版
/admin/category/add/81/142
这是我的路由配置:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRouteLowercase(
"Admin_LogOn",
"Admin/{controller}/{action}/",
defaults: new { controller = "Account", action = "LogOn" },
constraints: null
);
context.MapRouteLowercase(
"Admin_Category_List_Add",
"Admin/{controller}/{action}/{id}/{cid}/{pid}",
defaults:
new
{
controller = "Category",
action = "Create",
id = UrlParameter.Optional,
cid = UrlParameter.Optional,
pid = UrlParameter.Optional
},
constraints: null
);
context.MapRouteLowercase(
"Admin_TwoParameters",
"Admin/{controller}/{action}/{id}/{cid}",
defaults: new { controller = "Manager", action = "Index", id = UrlParameter.Optional, cid = UrlParameter.Optional },
constraints: null
);
context.MapRouteLowercase(
"Admin_default",
"Admin/{controller}/{action}/{id}",
defaults: new { controller = "Manager", action = "Index", id = UrlParameter.Optional },
constraints: null
);
}