ramya
ramya

Reputation: 2780

change website content based on subdomain or url

I am working on a asp.net web application, where i need to manage different regions and sub regions, each Region and Sub-region will have their on master page design and will have their own content to be displayed on the website. Application is deployed at the single location but different domains and sub domains are pointing to same deployed location. I have to change displayed content as well as its design as per the accessed URL. Also there is a Main Region where all the content will be displayed.

What is the best method to implement this functionality in ASP.NET with SQL Server.

Upvotes: 0

Views: 1596

Answers (1)

Paul Alan Taylor
Paul Alan Taylor

Reputation: 10680

You have a couple of issues to solve here. First, you need to know which host header that the user is using to access the site.

You can get this on any page with:-

HttpContext.Request.Url.Host

Second problem is conditional display of content depending on which hostname you've found. Your question talks about each sub-domain having it's own master page.

You should probably look at this article which explains how to programmatically select a master page.

http://msdn.microsoft.com/en-us/library/c8y19k6h%28v=vs.100%29.aspx

With those two elements in place, your process becomes:-

  • Detect the hostname
  • Serve the correct master page based on derived hostname

Upvotes: 1

Related Questions