【发布时间】:2015-12-05 03:12:28
【问题描述】:
我正在实现以下线程中讨论的方式: Adding company name in Routes mvc 4
routes.MapRoute(
name: "Default",
url: "{CompanyName}/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
constraints: new { CompanyName = "Company1|Company2|Company3" }
);
但是如何从另一个动作的代码中调用它,即Company2/Home/Index?
目前,我正在使用return RedirectToAction("Index", "Home"),但想在其中添加Company2并动态重定向。
【问题讨论】:
-
return RedirectToAction("Index", "Home", new { CompanyName = "Company2" });
标签: asp.net-mvc model-view-controller routes asp.net-mvc-routing