Multiple domains with the ASP.NET 2.0 HttpHandler - Adam Heunis tech talk
in

dotnet.org.za

South African .NET Developer Portal

Adam Heunis tech talk

Software mostly, but other techie stuff as well. I primarily use Notepad, Visual Studio, the Command Prompt, XmlSpy, SQL Server, MySQL and Photoshop. I speak
C# (incl. OO), XML, XSL, ASP.NET, VB.NET, VB6, SQL, UML and XForms.

Multiple domains with the ASP.NET 2.0 HttpHandler

Here is my problem: I own many domain names (too many my wife says Smile) and I want to be able to do serve .NET pages for potentially each of them, but I don't want to have an account for each domain name. Essentially I want the users not to know that they are using the same application on a server for different domains. I don't want to redirect either as the urls will give it away.

I'm sure many other domain junkies must have this same issue. To achieve this I do the following:

Firstly I use Brinkster.com as my domain host. The allow up to 100(!) domains to point to the same application. That is step 1. Not many other hosts will allow that. Please comment if you know about other hosts that do.

Secondly I use a an httphandler to interrupt all my root .aspx requests. This handler then uses an xml file that I've created to match a domain with a folder in my website. Then I use fairly basic string manipulation to rebuild the request url. Finally I use:

IHttpHandler hand = (Page)PageParser.GetCompiledPageInstance(physicalFile, null, context); // For .NET 1.1

or

IHttpHandler hand = BuildManager.CreateInstanceFromVirtualPath(physicalFile, typeof(Page)) as IHttpHandler; //For .NET 2.0 with Medium Trust Level

hand.ProcessRequest(context);

to "run" the new url.

This works like a treat and the users are none the wiser. If you don't believe me check out my personal website, photography website and Boesmansriviermond (my town). All are running from the same brinkster account.

It be happy to get into specifics if anyone is interested. Please email me at adam[lastname - begins with an H]@hotmail.com.

Published Jul 23 2006, 11:32 AM by attie
Filed under: ,

Comments

 

Clinton Cherry said:

Can you please upload your source code for this?

Seems like a great idea

August 30, 2006 6:15 AM
 

Aaron said:

Hey Adam.  I was searching for info on how to do this exact thing and google brought me here.  Yes, I'd like to whatever additional details you'd be willing to share about how you do this.

November 13, 2006 5:04 PM
 

Kenton Wilson said:

Hey Adam,

I used this very same technique in .net 1.1 and it worked great.  I'm trying the same technique that you seem to be using in 2.0 and it's not updating the brower's url.

My scenario is much like yours... I want to be able to virtually "host" multiple sites on my one site.  Specifically, when my site is called via an ip address (internally), I'd like to show a virtual domain name in the brower's url but load a physical page (master page) from my web app's folder.  I will then use parameters passed to load a theme in the master page for that virtual site.

You mentioned you would be willing to pass on your example code.  I'd love to see it if it's still available.

November 20, 2006 10:59 PM
 

Michel said:

I have the same problem on webhost4life. Can you help me to do the same with ASP.NET 1.1 ? Thanks.

December 13, 2006 3:22 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Powered by Community Server (Commercial Edition), by Telligent Systems