Bug: Application Creation via AppCmd.exe

I was trying to find the syntax in AppCmd.exe to convert an existing virtual directory say - myVdir to be an application.
Obviously, the first step is to create the virtual directory. (I know I can do both with appcmd add app bla bla and create the associated vdir). but I was looking for the way to do it as the IIS Manager, right mouse - Convert to Application)

Step 1 - create the vdir
appcmd add vdir /app.name:"default web site/" /path:/myVdir /physicalPath:c:\temp\vdir
Output:
VDIR Object "default web site/myVdir" added

Then, I spent sometime looking on how to 'covert' myVdir to an application itself, in other words make the <virtualDirectory> itself as "/" or root vdir which indicates that it is an application staring point in IIS 7.0. But I got no luck :( maybe my mind got stuck after playing with AppCmd.exe for 3hrs. I can't use "appcmd set vdir" as there's no options for application, and I can't apply "appcmd set app" because it is not an application yet, it is just a Vdir using the root application.

Anyway, so after awhile I decided to use "appcmd add app" and hoping that IIS detects that the vdir already defined, and it will just reconfigure it as an application. So,
Step 2 - create the app
appcmd add app /site.name:"default web site" /path:/myVdir /physicalpath:c:\temp\vdir
Output:
APP Object "default web site/myVdir" added
VDIR Object "default web site/myVdir/" added

Voila!!! I was so happy, I thought it works as I was expecting duplicate element error :) but no error msgs. So I fired up IIS Manager to check! Zzz... I can't no longer expand the "default web site", and got an error msgs saying "An item with the same key has already been added". Sigh! so the configuration store accepted the duplicate entry and now it complaints! Argghhh!!!

Now, to fix this! again I found something interest. You can do it via UI in Vista, but not W2k8 Beta 3. For vista, just click OK to ignore the error, then View Applications - right click on myVdir, and then click Remove. Now, if you try the same steps in W2k8, after the delete confirmation dialog box, you got back the "An item bla bla ........." error msgs again :) To fix this for W2k8, go to applicationHost.config file and manually remove the duplicate entry. And I conclude this as a validation bug of appcmd when trying to manipulate the configuration store.

Mm....now! I'm back at where I started. so is it possible to 'Convert to Application' for existing vdir via AppCmd.exe ???

Updated - 170707
I should have mentioned that W2k8 I'm using is from April CTP, you won't get the UI error in June CTP.
Also, according to Microsoft - it is acceptable to have same /alias inside the different application. In my case, the vdir of the default web site/ root application will never get reference as the /myVdir application's vdir definition kicks in first. Mm.... I still don't like the idea, why it accept both when only 1 is technically working?

Anyway, for my question - no way to 'covert to application' from appcmd.exe in 1 step :)
You can however, first delete the vdir, then create the app.....  two steps at least.

Published Sun, Jul 15 2007 21:32 by qbernard

Comments

# Mike Volodarsky said on 25 July, 2007 10:35 AM

Hi Bernard,

Thanks for posting about this issue!

You've exposed one of the many cases where runtime validation rules for configuration are different from the base configuration validation rules.  This is a necessary evil of the new configuration system - there is simply no way to encode and express the richness of runtime validation into a declarative configuration store.  The .NET configuration system is based on code and it can do a little more validation on the configuration system itself, but still not enough to completely describe the validation done by a runtime consumer of it.  In most of these cases, we try to do validation at runtime and give decent errors when we detect stuff that doesnt make sense, but then again, this doesnt describe every possible way you could configure the server.

In this case, we consider this behavior a bug in the UI because it does not allow you to correct the condition.  From the AppCmd perspective, the delete vdir/create application approach is the answer here.  In IIS7, we think a lot more strictly about the difference between vdirs and applications - an application is a completley different beast from vdir unlike IIS6, where it was simply a vdir marked for application isolation.  You can read one of my recent posts on the subject here: mvolo.com/.../Creating-IIS7-sites_2C00_-applications_2C00_-and-virtual-directories.aspx.

Thanks,

Mike

# qbernard said on 26 July, 2007 09:27 AM

Thanks Mike, and I do aware of the redefinition between site, vdir and app objects in IIS 7.0 and came out with these.

- A Web site must contain at least one application.

- A Web application must contain a root virtual directory.

- A virtual directory belongs to only one application

News

Search

Go

This Blog

Tags

Archives

IIS Sites

MVPs - MVPs

IIS Related

Syndication