Solved

Use different templates based on URL

Posted on 2008-06-12
3
185 Views
Last Modified: 2011-10-03
Hi.  I am close to launching two websites that use the same web application, but each uses a different stylesheet for the same master page.  Currently I am storing a session variable that indicates which "site" the user is currently on and I set the appropriate stylesheet.

Basically, the template displayed must depend on the URL.  When I launch the site next week, what is the best way to achieve this?

I would also like to retain the URL, so if there is a NoticeBoard.aspx page, then the person coming in on ThisUrl.com should see ThisUrl.com/NoticeBoard.aspx, and the user coming in on OtherUrl.com should see OtherUrl.com/NoticeBoard.aspx.

Thanks.
0
Comment
Question by:corebiz
  • 2
3 Comments
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 21774053
I suggest that you create two theme folders, for example "This" and "Other", and put the style sheets in those.

In the Page_PreInit method of the master page, check the value of the Page.Url.Host property, and set the Page.Theme property accordingly. This will automatically include a link tag in the header to include the correct style sheet.
0
 

Author Comment

by:corebiz
ID: 21779273
I've already handled the setting of the stylesheets.  I guess I'm just new at the game of setting up the servers to have urls pointing to the same web application and then for the web application to decipher which URL is being used.

I did just want to make sure I wasn't completely missing something here.

So, the URL checking is easy enough then - is there any help/tips you can give on setting up the server for the two domains?
0
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 21783366
To make two domain names being handled by the same web application, you simply:

1. Make sure that both domain names point to the server.
2. Add both the domain names in the settings for the site in the IIS manager.

When someone browses to either domain name, the Page.Url.Host property will contain the domain name they used.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction (All good things must come to an end (http://en.wikipedia.org/wiki/All_Good_Things...))The original MySQL API (http://php.net/manual/en/book.mysql.php) has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all current…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question