Creating Virtual Directory for ASP.NET 2.0 programmatically

For all of you programmers out there, who develop for 1.1 and 2.0 on the same machine – this trick can be quite useful for you !

If you’re still using IIS, you’ll want to create a VD(Virtual Directory) which support 2.0 for those application developed for that version, and still use VD which support 1.1 for your older application. Running an 2.0 application with VD of 1.1 (and vice versa, of course) will not work.
Where’s the catch you may ask ?
Well, if you add a new virtual directory, you may notice that the chosen (default) version is the one you have in the Default Web Site. This can cause some annoying problems as some of your developers(or your server(s) administrator(s)) will define 2.0 as their default while the others will define 1.1 as their default. Just mentioning “define a new Virtual Directory for the application X” won’t be enough.

The trick is to create a new Virtual Directory in the old fashion way, and just after it – call

%windir%\Microsoft.Net\Framework\[wanted version]\aspnet_regiis.exe -s w3svc/1/root [your Vitual directory name]

But hack, why do you need to remember all of this ?

Use the new(here is the old, without 2.0 support), improved, stylish, with 2.0 support – VDCreator:

VDCreator bin(EXE & Config only) (4.81 KB)

VDCreator Source (39.56 KB)

last but not least 

Ken helped me on this one so thanks mate !


Oren Ellenbogen