IIS 6.0 programmatically - the problem of creating virtual directories And do not install it as an application

Therefore, I create the virtual directory in IIS 6.0 programmatically, but I follow the only MSDN documentation (or another) when creating the virtual directory, but the documentation I have in

http://msdn.microsoft.com/en-us/library/ms525598(VS.90).aspx

This is the reason that my virtual directory is an application in IIS. I tried to use the metabase properties page:

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/cde669f1-5714-4159-af95-f334251c8cbd.mspx?mfr=true

But in a sea of ​​options, I'm not sure what properties I need to set in order to stipulate it strictly as a virtual directory:

DirectoryEntries vdirs = site.Children;
DirectoryEntry newVDir = vdirs.Add(vDirName, (className.Replace("Service", "VirtualDir")));

newVDir.Properties["Path"][0] = phyPath;
newVDir.Properties["AccessScript"][0] = true;
newVDir.Properties["AppFriendlyName"][0] = vDirName;
newVDir.Properties["AppIsolated"][0] = "0";
newVDir.Properties["AppRoot"][0] = "/LM" + metaBaseFullPath.Substring(metaBaseFullPath.IndexOf("/", ("IIS://".Length)));

newVDir.CommitChanges();
+5
3

metabase.xml %systemroot%\windows\system32\inetsrv - . IIS MMC, , :

myvdir , , metabase.xml:

<IIsWebVirtualDir   
    Location ="/LM/W3SVC/1/root/myvdir"
    AccessFlags="AccessRead | AccessScript"
    DirBrowseFlags="DirBrowseShowDate | DirBrowseShowTime | 
                    DirBrowseShowSize | DirBrowseShowExtension | 
                    DirBrowseShowLongDate | EnableDefaultDoc"
    Path="D:\websites\myapp\www\myvdir" >
+1

, . :

newVDir.Properties["Path"][0] = phyPath;
newVDir.Properties["AccessScript"][0] = true;

newVDir.CommitChanges();

, ,

+1

, IIsWebVirtualDir ( ) , . "AppDelete".

IIsWebVirtualDir...

newVDir.Invoke("AppCreate", 1);

newVDir.Invoke("AppCreate2", new object[] { 0 });

IIsWebVirtualDir ...

newVDir.Invoke("AppDelete");

Information about these methods and their parameters can be found in the ADSI documentation, but you need to convert the code samples to C # syntax.

+1
source

All Articles