Solved

Use different templates based on URL

Posted on 2008-06-12
3
176 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now