IIS7、web.config 只允许在网站的目录/uploads 中使用静态文件处理程序 [英] IIS7, web.config to allow only static file handler in directory /uploads of website

查看:37
本文介绍了IIS7、web.config 只允许在网站的目录/uploads 中使用静态文件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我认为可能的话,我该如何修改我的 web.config 以将子目录设为静态——里面的文件只会作为静态文件处理,即使它的名称是aspx"或其他名称?谢谢.

解决方案

将以下内容添加到包含您希望仅用作静态内容的文件的文件夹中的 web.config 文件:

<预><代码><配置><system.webServer><处理程序><清除/><添加名称=静态文件"路径="*" 动词="*"modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"资源类型=要么"requireAccess="读取"/></处理程序><静态内容><mimeMap fileExtension=".*" mimeType="application/octet-stream"/></staticContent></system.webServer></配置>

If it's possible which I think so, How do I modify my web.config to make a sub directory static -- files inside will only processed as static file, even if its name is "aspx" or something else? Thanks.

解决方案

Add the following to a web.config file in the folder containing the files you wish to be served only as static content:

<configuration>
    <system.webServer>
        <handlers>
           <clear />
            <add 
                name="StaticFile" 
                path="*" verb="*" 
                modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" 
                resourceType="Either" 
                requireAccess="Read" />
        </handlers>
        <staticContent>
            <mimeMap fileExtension=".*" mimeType="application/octet-stream" />
        </staticContent>
    </system.webServer>
</configuration>

这篇关于IIS7、web.config 只允许在网站的目录/uploads 中使用静态文件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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