1

I'm planning a multicountry site. I will be using a subdomain for each country, for example:

uk.example.com (UK)
us.example.com (USA)
ca.example.com (Canada)

Each country will have sections, but not all the countries will have all the sections.

So for example, the UK site will have available 3 sections, the US site will have 5 sections and the CA sill have all the available sections (suppose there are 8 sections).

I need in some way to turn sections ON and OFF in each subdomain and in interior pages change options (for example in UK I have to show a different money symbol and maybe use a different text).

Apart of that, I need to use some kind of parameter according the subdomain used (the info is in the same database, so if the subdomain is UK I need to retrieve only the info for UK).

The easy way would be to replicate in each subdomain the code behind, but I don't want to do it this way, because when I change something in the code, I would have to replicate for all the others subdomains.

I'm using C#.

Any suggestions and help are much appreciated :)

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
delavega
  • 79
  • 8
  • if you use for each country a subdomain, you need for each subdomain a ssl certificate (in case you require one), this gets expensive. – NickD Oct 08 '11 at 16:54

1 Answers1

2

You can use routing (like MVC does) with your ASP.NET application. In this way you can set variables based on the subdomain and use them in your application logic. As Snoopy mentioned, you'd need to get a wildcard certificate if you want secure your application. They're not that much more expensive than a standard SSL cert. That said, you may want to consider using something like this instead:

domain.com/{country}/{region}/{your_page}

Regardless of your choice, routing is definitely the way to go.

Introduction to Routing with ASP.NET Webforms

After you wrap your head around routes, there are a lot of resources for routing sudomains that should get you on your way.

Brent
  • 411
  • 4
  • 11
  • Thank you, but if I just use regular .NET (not MVC), what would be the best approach? – delavega Oct 08 '11 at 18:36
  • if it is 4.0 (vs2010) you can use Routing, otherwise you can try a rewriting tool like urlrewriting.net – Adrian Iftode Oct 08 '11 at 18:54
  • You can use routing with ASP.Net. Check out the link I posted. – Brent Oct 11 '11 at 13:51
  • @delavega Are you done redirect website to sub domain based country region? I am trying for a long time to redirect. I am using ASP.Net. Is this possibe means please post some code which you have used for redirecting based country? – kasim Jan 29 '15 at 06:21