开发者

ASP.net subdomain for each country using the same code with parameters

开发者 https://www.devze.com 2023-04-11 11:36 出处:网络
I\'m planning a multicountry site. I will be using a subdomain for each country, for example: uk.example.com (UK)

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 O开发者_StackOverflow中文版FF 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 :)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号