IIS 6.0以编程方式 - 创建虚拟目录时出现问题而不将其设置为应用程序

pgh*_*ech 5 c# iis iis-6

所以我在程序上在IIS 6.0中创建一个虚拟目录,但我正在关注创建虚拟目录的唯一MSDN(或其他)文档,但是我在的文档

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

导致我的虚拟目录成为IIS中的应用程序.我试图使用配置数据库属性页面:

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

但是在选项的海洋中,我不确定我需要设置哪些属性来严格地将其规定为虚拟目录:

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();
Run Code Online (Sandbox Code Playgroud)

Kev*_*Kev 1

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" >
Run Code Online (Sandbox Code Playgroud)