可以添加MIME类型的web.config没有可能打破了网站? [英] Possible to add MIME type to web.config without possibly breaking the site?

查看:402
本文介绍了可以添加MIME类型的web.config没有可能打破了网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的IIS网站被添加了.7z压缩文件扩展名的支持的一个web.config文件。当我后来又增加在服务器级别的全球.7z压缩的支持,这个网站被打破 - IIS管理器抱怨说,它不能添加型'mimeMap'重复的集合项......和所有的Web请求胃内CSS文件,一个HTTP 500错误结束。

I had a web.config in one of the websites on my IIS that was adding a support for .7z file extension. When I later added a global .7z support at the server level, this site was broken - IIS Manager is complaining that it "cannot add duplicate collection entry of type 'mimeMap'..." and all web requests to i.g. CSS files ended with an HTTP 500 error.

我在网站的web.config使用这个:

I was using this in the site's web.config:

<system.webServer>
    <staticContent>
        <mimeMap fileExtension=".7z" mimeType="application/x-7z-compressed" />
    </staticContent>
</system.webServer>

有可能其他一些语法,将增加7Z到,只有当它尚未定义的列表?

Is there maybe some other syntax that would add 7z to the list only if it wasn't defined yet?

推荐答案

据<一个href=\"http://blogs.msdn.com/b/chaun/archive/2009/12/04/iis7-error-cannot-add-duplicate-collection-entry-of-type-mimemap-with-unique-key-attribute-fileextension.aspx\">this,你应该的删除的以不同的形式加入之前在特殊配置的全局设置。

According to this, you should remove the global setting in the special config before adding it in a different form.

Explcitly:

Explcitly:

<system.webServer>
    <staticContent>
        <remove fileExtension=".7z" />
        <mimeMap fileExtension=".7z" mimeType="application/x-7z-compressed" />
    </staticContent>
</system.webServer>

当然,这并不能真正帮助您的现在的,你还不如彻底删除本地设置(因为它可能与全局设置一致)。但是,如果你已经知道,当你添加本地7zip的支持这一回,你就不会遇到现在的错误...

Of course this doesn't really help you now as you might just as well drop the local setting completely (as it's likely to coincide with the global setting). But if you had known this back when you added local 7zip support, you wouldn't have encountered the error now ...

这篇关于可以添加MIME类型的web.config没有可能打破了网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆