Click here to Skip to main content
13,446,762 members (40,068 online)
Click here to Skip to main content
Add your own
alternative version


36 bookmarked
Posted 7 Mar 2005

New Multisite DLL Or How to develop .NET project in a Root

, 8 Apr 2005
Rate this:
Please Sign up or sign in to vote.
Utility to ease .NET development.


How many times you probably wished that you can develop your .NET project in the root folder or host multiple websites on Win XP. If at least one time, then read on.

The problem with developing in the root is that VS does not really support that (although doable). Also, very often, I work on several projects or just simply would like to have a project in its own folder so that when I need I can easily bring it up for debugging/modifying without messing up all other projects.


I have come across multisite.dll (probably very well known) which allows to map different host names to different URLs. So I could setup to /project1 folder, to /project2 folder ... But this DLL does not work with .NET. The only thing it works well with is simple HTML, which basically makes it worthless.

But that made me wonder, what prevents it from working with .NET. After reading some documentation on ISAPI, I figured that the problem lies in how it handles the request.

When browser hits the IIS with, IIS converts the URL "/default.aspx" to physical path "C:\inetpub\wwwRoot\default.aspx". Only then that DLL gets its grip on the request and modifies physical path to the correct path "C:\inetpub\wwwRoot\project1\default.aspx". The first thing ASP.NET application does is, check for web.config and global.asax in the root folder and since the URL has not been changed the ASP.NET looks for those files in "\" folder and not in "\project1" folder, thus skipping to load config.asax or web.config making any serious project development with that version of Multisite.dll useless.

After I had realized that, I understood that the solution is to modify URL and not a physical path. After reading documentation more carefully, I discovered that SF_NOTIFY_PREPROC_HEADERS in conjunction with GetHeader, SetHeader will do exactly what I need.

  1. Browser hits the IIS with
  2. DLL modifies it to

Everything else is the same as if we would hit the URL from the beginning. ASP.NET finds proper global.asax and web.config and works without even knowing that modification has been done.

Implementation of New Multisite DLL

  1. This step need to be done only once when you install my multisite.dll. Copy multisite.dll and config.ini in some folder then register it as ISAPI filter with IIS.
  2. Let's say you have .NET project. Let's say Project1. And you want it to be on
  3. Modify HOSTS file in C:\WINDOWS\system32\drivers\etc. Add a new line:
  4. Modify config.ini in the same folder where mulitsite.dll is. Add a new line: = /Project1

    Note, not www. Becasue www. will be stripped out automatically so it works as in real world.

  5. Restart IIS server. After that every time you hit the URL will be converted to and everything will work. When you are done with the project, you simply need to copy everything to root folder of the production website. No modifications needed.

Important Notes

  1. Safely assume that your project is working from the root so that all images, css files, js files might be referenced from the root. No need to append the project name and then when moved to production rename all of them.
  2. Where possible use root "/" or "~" symbol of .NET in constructions like Response.Redirect("~/mypage.aspx") Or Response.Redirect("/mypage.aspx"). Do not use your project name. The construction Response.Redirect("~/mypage.aspx") will be translated to Response.Redirect("/project1/mypage.aspx"). Because of that multisite DLL will not modify the path. I.e., the path will not be touched and will be passed as is to IIS. (The key here is that first folder in URL matches mapping folder).
  3. In current implementation you need to restart IIS so that all changes in config.ini will be loaded.
  4. Debug is fully supported but because when you press F5 in Visual Studio, it opens http://localhost/.... You need to either map localhost to /Project1 or have a separate browser window point to and do all testing there. It's up to you which way to go but if you mapped localhost then do not forget to unmap it. Or you will not be able to access any other file on IIS outside of Project1 folder.
  5. It's crucial to have in config.ini the project folder to start with '/' symbol.
  6. Do not prefix names with www. in config.ini. www. is stripped out from the request to make it work like real web application. If you want both www. and non www. version of the working site, you need to add two lines to host file though. One for www. name and one without www. name!


I found that this small utility is very useful in my development work. I can keep all my projects running on my development machine and if needed easily be modified and uploaded on a production server. No need to run a "Replace ALL" to eliminate the project name.

Also it came very handy on my production server Ms.Piercing where I have multiple websites and instead of using the ability of IIS to run multiple instances of WWW, I am using my DLL to do that (it seems to me more lightweight).

If you have any questions about this DLL feel free to send me an email (remove nospam) or visit my website. I am planning to write next version which will not require to restart IIS every time you modify config.ini.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
I am a Senior Software developer who does a consulting work for several companies. Mostly it's an E-Commerce project.

I do have my own venture. Small online store my wife runs. Body Jewelry. Also visit Piercing info Cool thing is that nor I nor my wife has any piercings. My new website is Belly ring

You may also be interested in...


Comments and Discussions

Question4.0 version Pin
Glay200924-Jan-13 18:09
memberGlay200924-Jan-13 18:09 
GeneralBig Thanks Pin
thewondersnarf11-Mar-11 0:02
memberthewondersnarf11-Mar-11 0:02 
GeneralMultiSite for XP64 Pin
metastar21-Jan-11 20:53
membermetastar21-Jan-11 20:53 
Recompiled to run on XPx64 platform...[^]
QuestionHow do u acutally start the multiple sites at the same time? Pin
RichTrawinski271-Mar-10 16:56
memberRichTrawinski271-Mar-10 16:56 
AnswerRe: How do u acutally start the multiple sites at the same time? Pin
Gevorg2-Mar-10 2:44
memberGevorg2-Mar-10 2:44 
GeneralWorks well, except for long URLs Pin
naasking21-Jul-09 6:55
membernaasking21-Jul-09 6:55 
QuestionMaybe I'm missing something Pin
Mike william27-Jan-07 16:31
memberMike william27-Jan-07 16:31 
GeneralWin 2k Pin
maxwell_hung13-Dec-05 0:35
membermaxwell_hung13-Dec-05 0:35 
GeneralRe: Win 2k Pin
Gevorg14-Dec-05 17:36
memberGevorg14-Dec-05 17:36 
Questiondoesn't like classic asp include files? Pin
tfs_mag17-Oct-05 16:26
membertfs_mag17-Oct-05 16:26 
AnswerRe: doesn't like classic asp include files? Pin
Anonymous19-Oct-05 5:18
sussAnonymous19-Oct-05 5:18 
GeneralDebugging Pin
ekhanh10125-Aug-05 7:31
memberekhanh10125-Aug-05 7:31 
GeneralRe: Debugging Pin
Gevorg25-Aug-05 15:21
memberGevorg25-Aug-05 15:21 
GeneralRe: Debugging Pin
ekhanh10125-Aug-05 15:30
memberekhanh10125-Aug-05 15:30 
GeneralRe: Debugging Pin
ekhanh10125-Aug-05 15:52
memberekhanh10125-Aug-05 15:52 
GeneralGreat! Pin
Coderproj15-Jun-05 6:43
memberCoderproj15-Jun-05 6:43 
GeneralWorking perfect after a few restarts... Pin
Richard Bladh28-Apr-05 5:52
memberRichard Bladh28-Apr-05 5:52 
QuestionWhich DLL? Pin
Arman27-Apr-05 7:45
memberArman27-Apr-05 7:45 
AnswerRe: Which DLL? Pin
Gevorg8-Apr-05 15:32
memberGevorg8-Apr-05 15:32 
QuestionIt won't work. What's wrong? Pin
Arman27-Apr-05 7:41
memberArman27-Apr-05 7:41 
AnswerRe: It won't work. What's wrong? Pin
Gevorg8-Apr-05 15:59
memberGevorg8-Apr-05 15:59 
AnswerRe: It won't work. What's wrong? Pin
dr_fission14-Jul-05 4:37
memberdr_fission14-Jul-05 4:37 
Generalalmost perfect Pin
jfincke9-Mar-05 5:07
sussjfincke9-Mar-05 5:07 
GeneralRe: almost perfect Pin
Gevorg9-Mar-05 8:41
memberGevorg9-Mar-05 8:41 
QuestionHow is this different than using Host headers in IIS? Pin
Anonymous7-Mar-05 12:45
sussAnonymous7-Mar-05 12:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180318.2 | Last Updated 8 Apr 2005
Article Copyright 2005 by Gevorg
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid