[英]IIS 6.0 programmatically - Problem creating virtual directories AND not setting it as a Application
So I am creating a virtual directory in IIS 6.0 programmically, but I am following the only MSDN (or other) documentation on creating a virtual directory, but the documentation I have at 所以我在程序上在IIS 6.0中创建一个虚拟目录,但我正在关注创建虚拟目录的唯一MSDN(或其他)文档,但是我在的文档
http://msdn.microsoft.com/en-us/library/ms525598(VS.90).aspx http://msdn.microsoft.com/en-us/library/ms525598(VS.90).aspx
Is causing my virtual directory to be an application in IIS. 导致我的虚拟目录成为IIS中的应用程序。 I was trying to use the metabase properties page:
我试图使用配置数据库属性页面:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/cde669f1-5714-4159-af95-f334251c8cbd.mspx?mfr=true http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/cde669f1-5714-4159-af95-f334251c8cbd.mspx?mfr=true
But in the sea of options I am not sure what properties I need to set 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();
Try not setting the app-pool specific entries. 请勿尝试设置特定于应用程序池的条目。 so just:
所以就:
newVDir.Properties["Path"][0] = phyPath;
newVDir.Properties["AccessScript"][0] = true;
newVDir.CommitChanges();
Haven't done this in awhile, but i think thats it 有一段时间没有这样做,但我认为就是这样
The metabase.xml
file in %systemroot%\\windows\\system32\\inetsrv
is your best friend. %systemroot%\\windows\\system32\\inetsrv
的metabase.xml
文件是您最好的朋友。 If you create a virtual directory in IIS MMC you can see the requisite attributes attributes you need to set: 如果在IIS MMC中创建虚拟目录,则可以看到需要设置的必需属性属性:
Here I created a virtual directory called myvdir
in a site, this is the metabase configuration persisted to metabase.xml
: 在这里,我创建了一个名为的虚拟目录
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" >
As far as I remember, you cannot set an IIsWebVirtualDir to be an application (or not) by properties, but by calling methods on it. 据我所知,你不能通过属性将IIsWebVirtualDir设置为应用程序(或不是),而是通过调用它上的方法。 In your case you would have to call "AppDelete".
在您的情况下,您将不得不调用“AppDelete”。
newVDir.Invoke("AppCreate", 1);
or 要么
newVDir.Invoke("AppCreate2", new object[] { 0 });
newVDir.Invoke("AppDelete");
Details about these methods and their parameters can be found at the ADSI documentation, but you have to convert the code samples there to C# syntax. 有关这些方法及其参数的详细信息,请参阅ADSI文档,但您必须将其中的代码示例转换为C#语法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.