Using OnAppStart to determine the site's frosting
Posted on 2011-09-08
How (or if) to use the Global.asa as a way to clone a series of sites with a common code base but varying front-end elements.
I have a donut shop and have found that if I deploy a series of websites - one for each of the donut types I manufacture (myGlazedDonut.com; mySprinkledDonut.com; myPlainDonut.com, and so on) - I'm better able to serve the interests of my customers than if I host one central 'DonutsRUs.com' domain. (taken, darnit).
I'm thinking the best code reuse will be one backend tier that drives multiple websites, one per frosting option. So I'd like to code a webapp that understands which frosting facade to present based on which domain it's running within.
So if the app wakes up to find it's running in the 'myFrostedDonut.com' domain it knows to display 'sales@myFrostedDonut.com' for the email address, it knows which .jpgs to use for Banners and Footers, it knows which google-analytics code to use. It even knows that on the 'Contact Us' the reader will see: Hi, from your loyal friends at Plain Donuts. Did you know that plain donuts are much better for you than those fattening things found at places like myFrostedDonuts.com.
Point is there are a lot of different 'search/replace' types of operations taking place in code. Usually I've used the web.config to store global variables but the above scenario is more complex than just a database connection string - there are a lot of exception conditions to account for, not every property has a one-to-one relation to each other domain.
I'm thinking I want to add logic at the Global.asa but need to see some examples of how others have approached similar problems.