相关疑难解决方法(0)

IIS 7.5 applicationHost.config文件未更新

我目前正在使用Microsoft.Web.Administration(MWA)命名空间,以便调整我们的应用程序以使用新API配置IIS 7.5.我知道所有IIS级别的更改都应该在以下文件中表示(我在Win2K8-R2上):

%WINDIR%\System32\inetsrv\config\applicationHost.config

因此,当我使用该ServerManager对象提交配置更改时,应相应地更新该文件.

添加新的MIME类型(使用MWA编程)后,我没有看到任何更改applicationHost.config file,但我确实在IIS管理器窗口中看到了新的MIME类型,IIS可以正确识别此MIME类型.即使在重新启动操作系统后 - 配置文件也不包含新添加的MIME类型,但IIS管理器窗口会列出它.

因为我的应用程序池被强制为32位(Enable32BitAppOnWin64 = true),我认为相关的配置文件应位于%WINDIR%\SysWOW64\inetsrv\Config,但(如果它存在...) - 它也不会在代码提交更新后更改.

有人可以解释一下吗?我错过了什么(可能会查看错误的文件?)?有人可以对SysWOW64\inetsrv\config目录有所了解吗?

这是我添加MIME类型的代码:

ServerManager manager = new ServerManager();
ConfigurationElementCollection staticContentCollection = manager
    .GetApplicationHostConfiguration()
    .GetSection("system.webServer/staticContent")
    .GetCollection();

//MIMETypes is a string[] array, each object is {FileExt},{MIMETypeStr}
foreach (string pair in MIMETypes)
{
    string[] mimeProps = pair.Split(',');

    ConfigurationElement mimeTypeEl = staticContentCollection
          .Where(a => 
                   (string)a.Attributes["fileExtension"].Value == mimeProps[0])
          .FirstOrDefault();


    if (mimeTypeEl != null)
    {
        staticContentCollection.Remove(mimeTypeEl);
    }

    ConfigurationElement mimeMapElement = 
                  staticContentCollection.CreateElement("mimeMap");

    mimeMapElement["fileExtension"] = mimeProps[0]; …
Run Code Online (Sandbox Code Playgroud)

applicationhost iis-7.5 mime-types

28
推荐指数
1
解决办法
3万
查看次数

标签 统计

applicationhost ×1

iis-7.5 ×1

mime-types ×1