cycopepe cycopepe - 1 year ago 72
ASP.NET (C#) Question

mvc multiples routes for the same site

here is my problem I have an existing web site

requirement ask me to allow users to use the same site like this

so I modify the routes configuration (RouteConfig.cs)

name: "OrganisationRoute",
url: "{org}/{controller}/{action}/{data}",
org= "defaultsuborganisation",
controller = "Home",
action = "Index",
data = UrlParameter.Optional

I work for all the expected routes except for

Answer Source

Attribute routing like Div said may be the better way to go, but you can add a fixed route ahead of your OrganisationRoute in the RegisterRoutes() method like so:

 new { controller = "Home", action = "Index", id = UrlParameter.Optional}