1

I have two domains:

mydomain.com and mydomain.fr

They both correspond to the same IP address.

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

I am using ASP.NET MVC 3 and the default route is mapped to page A.

How can I achieve this ?


EDIT:

I tried to use the example provided but it seems not to work. Is it the right way to register the 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
    );  
}
Ofer Zelig
  • 17,068
  • 9
  • 59
  • 93
alexandrekow
  • 1,927
  • 2
  • 22
  • 40

1 Answers1

1

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

Check out this question: Is it possible to make an ASP.NET MVC route based on a subdomain?

Community
  • 1
  • 1
Ofer Zelig
  • 17,068
  • 9
  • 59
  • 93
  • _Is it the right way to register the custom route?_ Not exactly. Look at this specific answer to see how to work with custom routes: http://stackoverflow.com/a/2723863/290343 – Ofer Zelig Jan 30 '12 at 13:26