I have an application that I am creating for multiple clients. The only differences between clients is the stlye sheets and a few graphics. I would like to have each client just use a different URL that will show the core content with different css like the following:
myapplication/client1/mycontroller/myaction
myapplication/client2/mycontroller/myaction
Can someone give me some pointers on how to accomplish is in .NET MVC 4?
Additional Info:
I am only deploying a single instance of this application. I want the application to dynamically use the proper style based on the "client" portion of my url.
Example. client1 has a green background, client2 has a blue background. Other than that client1 and client2 are running the same web application.
I have the following in my RouteConfig.cs file:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "client1",
url: "client1/{controller}/{action}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "client2",
url: "client2/{controller}/{action}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Update with Solution:
Here is the answer that I was looking for:
routes.MapRoute(
name: "client",
url: "{client}/{controller}/{action}",
defaults: new { controller = "Home", action = "Index" },
constraints: new { client = "client1|client2" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);