Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Use different templates based on URL

Posted on 2008-06-12
3
Medium Priority
?
201 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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses

877 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