IIS7,web.config只允许在目录/上传网站中使用静态文件处理程序

时间:2010-01-14 01:41:48

标签: security iis-7 web-config httphandler

如果有可能我认为如此,我如何修改我的web.config以使子目录静态 - 内部文件只会作为静态文件处理,即使它的名称是“aspx”或其他什么? 感谢。

1 个答案:

答案 0 :(得分:42)

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

<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>
相关问题