ASP MVC 3 Domain Dependent Routing

I have two areas:

mydomain.com as well as mydomain.fr

Both of them correspond to the same IP address.

I want users to enter mydomain.com to view page A (Controller = "Application" Action = "A") and users type mydomain.fr to view page B (Controller = "ApplicationFR" Action = "B")

I am using ASP.NET MVC 3 and the default route is displayed on page A.

How can i achieve this?


EDIT:

I tried using the provided example, but it doesn't seem to work. The correct way to register a custom route?

public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.Add(new ExampleRoute()); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Application", action = "B", id = UrlParameter.Optional } // Parameter defaults ); } 
+1
iis-7 asp.net-mvc-3 asp.net-mvc-routing
source share
1 answer

You can do this by creating a new route and adding it to the route collection in RegisterRoutes in global.asax .

Have a look at this question: Is it possible to make an ASP.NET MVC route based on a subdomain?

+1
source share

All Articles