I am implementing the way discussed in the following thread: 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" }
);
but how to call this i.e. Company2/Home/Index
from code on another action ?
Currently, I am using return RedirectToAction("Index", "Home")
but want to add Company2
in it and redirect dynamically.
You just need to add CompanyName
to the route values.
return RedirectToAction("Index", "Home", new { CompanyName = "Company2" });