0

Possible Duplicate:
Is it possible to make an ASP.NET MVC route based on a subdomain?

My URL looks like

    http://Infosys-1234.teradata.com

Can I take the whole URL as a parameter by configuring my path as:

         routes.MapRoute(
    name: "Default",
    url: "{url}",
    defaults: new { controller = "App",
                    action = "GetDetailsById", 
                   // url = UrlParameter.Optional
                  }
           );

If not, suggest me an alternative. I want to take out Infosys-1234 as a parameter from the url.

Community
  • 1
  • 1
Bhushan Firake
  • 9,338
  • 5
  • 44
  • 79

1 Answers1

0
routes.Add("DomainRoute", new DomainRoute( 
    "{param1}.example.com",  "{action}/{param1}",
    new { controller = "Home", action = "Index", param1 = "" }  // Parameter defaults 
));

From http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx

Edit: Need to instead say param1 (parameter names)

If that doesnt work maybe this would be a better solution

routes.MapRoute(
    name: "Default",
    url: "{param1}.mydomain.com",
    defaults: new { controller = "App",
                    action = "GetDetailsById", 
                    param1 = ""
                  }
           );
Tony
  • 4,609
  • 2
  • 22
  • 32