Solved

Use different templates based on URL

Posted on 2008-06-12
3
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This video teaches users how to migrate an existing Wordpress website to a new domain.
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.

617 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