I watch the ISP and 'review-hosts' lists on a regular basis, and I see a lot of discussion about the cost of .NET hosting. For me, the search for hosting ended when I found www.OrcsWeb.com
. There is simply no better value -- anywhere. However, I agree that when you need to host sites for small clients that know they can purchase domain names for under $15/yr, and get simple web hosting for less than $5/mo, it's difficult to guide them into a .NET solution when the monthly hosting fee blows their entire budget. And then there's the issue of the small business developer trying to create sites both for learning, and as demonstration sites for potential clients.
I've tried to cut the cost of hosting for these low volume sites in various ways, including hosting from my home office with DSL. It works, but for me, that solution just isn't worth the hassle! For one thing, I can't afford to hire myself at programmer rates to do network administration. And the performance is pitiful when you try to demonstrate a site to clients when it's hosted at DSL speeds - especially with graphics.
My current solution to managing the cost of .NET hosting for small clients is to use a single shared-server account from my hosting service, and allow several domain names to resolve to that one site. I simply use the web request's URL to redirect from the root of my single web site to the appropriate directory and start page for each specific URL (domain name). This isn't quite as nice as when I hosted from my home office and let IIS sort out the domains using Host Headers to resolve IP address conflicts, but there isn't much of a downside from a developer's viewpoint.
Domain Name Services (DNS)
Since I only have one IP address for my account at the hosting service, I need to have several domains all point to that same address. Some hosting services will allow you to deal directly with their DNS in some way, but I prefer to use another 3rd party DNS service. I use www.ZoneEdit.com to handle both the DNS and, in many cases, mail forwarding for all of my domain names. I find the service from ZoneEdit is great. Their administration tools are very easy to use. The cost is also great - the first 5 domain names are free. The cost for additional domain names is also quite reasonable. You can also get totally free DNS services from www.MyDNS.com and Granite Canyon. These, and other free sites, are listed in ZoneEdit's FAQ - I admire that.
Now that I have several domain names that will all hit the Default.aspx page in my web's root directory, I've got to redirect traffic to the appropriate start page for each specific domain name. My site uses a separate subdirectory just off the web's root directory for each of the domains. The subdirectory name will appear in the client's browser address bar, so I keep the name short (2-3 characters).
The following C# code does the redirection to the appropriate subdirectory and start page based on the Request's URL.
private void Page_Load(object sender, System.EventArgs e)
string url = Request.Url.ToString().ToLower();
// get just the domain name for the swicth
if ( url.StartsWith( "http://" ) )
url = url.Substring( 7 );
int x = url.IndexOf( '/' );
if ( x > 0 )
domain = url.Substring( 0, x );
else domain = url;
// redirect based on the domain name
switch( domain )
Response.Redirect( "SC/Default.aspx", true );
Response.Redirect( "SS/Default.htm", true );
Response.Redirect( "SW/Default.aspx", true );
// unknown url
Response.Write("<h2>You got here (" + domain + ") by error.<br>" );
Response.Write( Request.Url.ToString() + "<br></h2>" );
The first few lines of code just insure that I have the basic domain name to perform the switch statement. Notice that for each domain, I use both the "www" reference and the domain name without "www". The DNS directs both forms of the name to the same IP address.
Also using my own DNS, I can setup as many different starting points for a particular domain as I wish. For example, I can have test.sharkcode.com redirect to a "staging" directory on this site that I use for final testing.
Since none of the subdirectories representing each domain are configured as an application in IIS, there are some special considerations. For instance, the first runtime error you may encounter results from the presence of a Web.config file in each of the application subdirectories.
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
You can correct this error by removing <authentication mode=... /> and <sessionState ... /> from each of the Web.config files. While you're at it, you may also want to set customErrors mode="Off" while you first test your new applications.
Also, since this is all really one large application, the /bin subdirectory only appears in the site's root directory. So all of your various application DLLs have to be moved to this one /bin subdirectory.
Database issues can be different at each hosting service. I have a single SQL Server database, so all of the tables for each individual application share the same database namespace. I simply prepend each table with the applications identifier - normally the subdirectory name.
One side effect of running your applications from a subdirectory is that your application's view of the directory structure matches the development environment of your localhost. By that I mean that MapPath("/") yields the root web directory, and MapPath("~") yields the root web with the application's directory in both development (localhost) and production.
Remember that profit margins are paper thin for everyone these days, especially hosting services. Don't expect them to be willing to setup and manage multiple sites within the same account without charging for that service - which I'm sure is roughly the cost of a separate account. I'm just happy that OrcsWeb (and I'm sure many other hosts) are satisfied to simply charge based on your site's traffic and storage requirements.
If you have a limited budget (read that as: "I work from my garage"), then you can probably create some great sites and cut the initial hosting costs, at least while the traffic to those sites is limited. As these small sites grow (and the clients begin to pay) upgrade to individual accounts - or join the big boys with a dedicated server.
Feel free to send your comments and let me know what you think: firstname.lastname@example.org
Steve Sharrock - www.AspAlliance.com/shark / www.SharkCode.com