IIS停止时会反转网站设置

时间:2012-03-21 15:48:33

标签: iis application-settings

我在配置IIS时遇到问题。我以编程方式在网站下创建一个网站和一个应用程序(虚拟目录)。在其他设置中,我在应用程序设置中添加了通配符应用程序映射。当IIS重新启动时,它会删除wilcard应用程序映射(以及其他一些设置,但为了简单起见,我只提到了wilcard映射)。我可以使用IIS管理器重新添加地图,但是当我重新启动IIS时,地图将被删除。但是 - 如果我添加通配符映射,然后在不重新启动IIS的情况下,首先使用浏览器访问该应用程序中的页面,然后任何后续IIS重新启动都不会导致映射消失。知道发生了什么事吗?

这是我的代码:

// root virtual dir object
string strRootVirtDirPath = "IIS://localhost/w3svc/" + strWebSiteID + "/root";
DirectoryEntry deRootVirtDir = new DirectoryEntry(strRootVirtDirPath);

// add new virtual dir
DirectoryEntry deNewVirtDir = deRootVirtDir.Children.Add(strAppName, "IIsWebVirtualDir");

deNewVirtDir.Properties["Path"].Value = strPhysicalDir;
deNewVirtDir.Properties["AppFriendlyName"].Value = strAppName;
deNewVirtDir.Properties["AppRoot"].Value = "/LM/W3SVC/" + strWebSiteID + "/Root/" + strAppName;
deNewVirtDir.Properties["AppPoolId"].Value = strAppPoolName;

// create the application
deNewVirtDir.Invoke("AppCreate", 1);

// commit changes
deNewVirtDir.CommitChanges();
deRootVirtDir.CommitChanges();
deNewVirtDir.Close();
deRootVirtDir.Close();

1 个答案:

答案 0 :(得分:0)

找出问题所在。它在Microsoft的知识库文章286196中有所描述:http://support.microsoft.com/kb/286196 我所有受影响的计算机都是Windows Server 2K3 R2,就像文章中所述。