Solved

Use different templates based on URL

Posted on 2008-06-12
3
178 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…
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.

863 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

19 Experts available now in Live!

Get 1:1 Help Now