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.

July 2006 - Posts

  • 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.

    Posted Jul 23 2006, 11:32 AM by attie with 4 comment(s)
    Filed under: ,
Powered by Community Server (Commercial Edition), by Telligent Systems