Click here to Skip to main content
Click here to Skip to main content

ASP.NET IIS Chameleon Tool

By , 15 Feb 2006
 

IIS Chameleon

Introduction

The ASP.NET IIS Chameleon is a tool to set one specific IIS Virtual Directory for a lot versions of the same web project.

Background

Some web projects in our company, have at least two versions:

  • "internal" - An internal beta version, where the team builds new features.
  • "launched" - All the already launched versions of the same project.

Our developers team need to code/correct both versions, depending on the necessity. Therefore, we need to switch faster between all these versions. Now, we're working with both versions: VS2003 (.NET Framework 1.1) and VS2005 (.NET Framework 2.0). We have designed a structure for our development machines, that makes it easy to apply changes and manage our source code, linked with specific virtual directories. Take a look at the structure design:

Logic Structure Model

Challenge

Each developer needs to map, as soon as possible, a specific version of a project (this one could be a random physical directory) to its IIS Web Shared Directory, so our team can start the maintenance or new implementations.

Older Solution

Well, for each "version change process", a developer needs to check in all files, get the specific/target version, then run aspnet_regiis.exe* for the specific metabase path and for the specific .NET Framework version. Another solution is running the Internet Information Services (inetmgr.exe), and then change the physical directory for a specific virtual directory, and the ASP.NET version too.

Newer Solution

Basically, we build a Windows Forms application tool named IISChameleon to join and automate some aspnet_regiis.exe and inetmgr.exe tasks. This tool was built with VS2005 and runs over .NET Framework 2.0. Our team has Windows XP Professional and Internet Information Services 5.1.

How To Use

This tool will load a list of all the virtual directories in your machine; just select the entry, change all values you want, and click the Update button, and hands on.

How IISChameleon Works

We take advantages of the System.DirectoryServices.DirectoryEntry class from System.DirectoryServices.dll and the process aspnet_regiis.exe.

DirectoryEntry* Class

Before manipulating entries on IIS with the DirectoryEntry class, we need to know the basic ideas about how IIS manages these entries. Each IIS entry (web site, web virtual directory, FTP virtual directory, ...) has a schema name and a collection of properties. All entries follow a hierarchy, with parent entries and children entries. These hierarchies are defined by a metabase path, which means that every entry, similar to physical directories, has a path. A sample of this hierarchy can be viewed in the following picture (a shot of the Metabase Editor* tool):

Metabase Editor Tool

To instantiate a DirectoryEntry, we basically need its metabase path.

DirectoryEntry directoryEntry = 
      new DirectoryEntry("IIS://localhost/w3svc/1/root");

The most of its properties should be accessed by indexers.

Console.Write( directoryEntry.Properties["Path"].Value.ToString() );

ASP.NET IIS Registration Tool (aspnet_regiis.exe)

This is used to discover all ASP.NET versions in the current machine, and to register a version of ASP.NET for a specific virtual directory.

Definitions File

The definitions.xml is used to store information about all the runtimes installed. So, maybe you will edit this one.

<runtimeVersions>
    <version alias="1.1"  baseDir="v1.1.4322"   full="1.1.4322.2032"/>
    <version alias="2.0"  baseDir="v2.0.50727"  full="2.0.50727.0"/>
</runtimeVersions>

IISChameleon User Interface

To build the user interface, we use some native controls coming from .NET Framework 2.0 and a simple JPGrid*.

Conclusion

IISChameleon, when combined with a standard structure of directories and versions, could be usual for developer teams, and support teams too.

References

License

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

joaoPaulo
Web Developer BENNER SISTEMAS
Brazil Brazil
Member
im just a developer,..

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalfind Dot net version installed in systemmembermjavid6225 May '07 - 21:54 
you can use this code to find Dot net version installed in system
RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
foreach (string strKey in reg.GetSubKeyNames())
{
Console.WriteLine(strKey);
}

GeneralAspNetIsInstalled always return falsememberMichael Freidgeim16 Aug '06 - 20:58 
I've noticed that INETMGRHelper.AspNetIsInstalled has a bug.
The current code has:
foreach (string line in outPut.Split("\r\n".ToCharArray()))
{
if (line.Trim() == "")
continue;
string path = line.Substring(0, line.IndexOf('\t'));
if (path.ToUpper().IndexOf(sitePath) == 0)
return path.IndexOf(aspNetVersion) != -1;
 
}

where expected line format is "W3SVC/1/ROOT/FSDNN/\t2.0.50727.0".
But path doesn't include version so path.IndexOf(aspNetVersion) always =-1.
The correct code should be
return line.IndexOf(aspNetVersion) != -1;
Also the possible output can be "Cannot find any installed version." instead of list of sites. Code should check that '\t' exist in the line.
The fixed code is:
foreach (string line in outPut.Split("\r\n".ToCharArray()))
{
if (line.Trim() == "")
continue;
//MNF 17/8/2006 Sample of output W3SVC/1/ROOT/FSDNN/\t2.0.50727.0
//In the correct output '\t' is always expected, but it could be output:"Cannot find any installed version." without \t
int nTabPos=line.IndexOf('\t');
if (nTabPos < 0) continue;
string path = line.Substring(0, nTabPos);
if (path.ToUpper().IndexOf(sitePath) == 0)
{
return line.IndexOf(aspNetVersion) != -1;// path doesn't include version, so it always returned false
}
}

 
Michael Freidgeim.
Blog: http://geekswithblogs.net/mnf/

GeneralUseful to be called from Web SetupmemberMichael Freidgeim10 May '06 - 19:27 
Thank you for the tool.
I used your class from my Web Setup custom installer.See my post[^] for the modifications that I've done.
 
Michael Freidgeim.
Blog: http://geekswithblogs.net/mnf/
GeneralVery nice!!!memberbrunzefb8 Mar '06 - 11:07 
we ran into a problem where sometimes the incorrect version of the .NET runtime was selected. This code makes it easy to write a program that will fix this problem
 
thanks,
 
Friedrich
JokeBoa idéiamemberPatrick Antonioli16 Feb '06 - 4:15 
Olá.. funcionou show de bola.. gostei...
 
_________________________
Patrick Antonioli

GeneralExcellent UtilitymemberMichael McKechney3 Jan '06 - 15:50 
I was just looking for such a tool! Excellent timing. When I was testing it for my sites, I found that it always resets the directory to the root, no matter where it started. I found it does this with this line of code:
 
DirectoryEntry iisAdmin = new DirectoryEntry(string.Format("{0}/Root", HashWebSites[record.Site]));

 
I was able to get it to keep my existing "sub-directory" setting by changing the code to:
 
string activeSite = HashWebSites[record.Site].ToString();
string subDirectory = record.MetabasePath.Replace(activeSite, "").Replace(parametros.Name, "");
subDirectory = subDirectory.Substring(0, subDirectory.Length - 1);
DirectoryEntry iisAdmin = new DirectoryEntry(string.Format("{0}{1}", HashWebSites[record.Site],subDirectory));

 
Thanks so much for this great utility.
 
Mike
GeneralDo you mean &quot;Chameleon&quot;memberPeter Ritchie29 Dec '05 - 10:08 
Chameleon[^]
 
PeterRitchie.com
AnswerRe: Do you mean &quot;Chameleon&quot;memberjoaoPaulo24 Jan '06 - 23:52 
thanks to point me that, i'm not too close with english.Big Grin | :-D
 
blitzkrieg bop!!
GeneralNeat Idea!memberHrusikesh28 Dec '05 - 4:26 
Sounds like a neat tool!
 
Can we have a bigger version of the screeenshots to look at?
Also, right now my company has most of its app running on v1.1. So is there a 1.1 version of this tool?
AnswerRe: Neat Idea!memberjoaoPaulo25 Jan '06 - 0:00 
thanks for your post!
 
well i tried to stretch the screenshotsd, i hope we can a better view now..Sniff | :^)
 
i have not a deadline to build a IISChameleon with v1.1..
but you can download the code and re-assemble the source code in a new VS2003 project.
 
thanks again!Cool | :cool:
 
blitzkrieg bop!!
 
-- modified at 6:03 Wednesday 25th January, 2006

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 16 Feb 2006
Article Copyright 2005 by joaoPaulo
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid