拒绝访问HTML页面 [英] Deny access to html page

查看:217
本文介绍了拒绝访问HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ASP.NET Web窗体项目。我创建了这个项目中的一个文件夹演示,并把这个文件夹 HelloWorld.html的英寸我需要拒绝访问该 HTML (重要的是不要ASP)页的所有用户。我怎样才能做到这一点?

我试过这种方式,但它没有工作(但它与ASP页面完美的作品)。

 <结构>
    <位置路径=演示/ HelloWorld.html的>
        <&的System.Web GT;
            <授权>
                <拒绝用户=*/>
            < /授权>
        < /system.web>
    < /地点>
< /结构>


解决方案

的web.config 是正确的。问题是这样的保证是正在经历ASP.NET管道文件。某些静态文件,如 HTML 的文件,都是由IIS提供了直接,所以它是绕过您的安全。

您可以通过在增加一个处理程序,迫使他们静态文件去通过ASP.NET管道< system.webServer> 你的web.config部分:

 <&处理GT;
    <添加名称=HTMLHandlerTYPE =System.Web.StaticFileHandler路径=* HTML动词=GET/>
< /处理器>

I have ASP.NET Web Forms project. I created a folder Demo in this project and put in this folder HelloWorld.html. I need deny access to this html (it's important not asp) page for all users. How can I do this?

I tried this way, but it didn't work (but it works perfectly with asp page).

<configuration>
    <location path="Demo/HelloWorld.html">
        <system.web>
            <authorization>
                <deny users="*"/>
            </authorization>
        </system.web>
    </location>
</configuration>

解决方案

Your web.config is correct. The problem is this secures files that are going through the ASP.NET pipeline. Certain static files, like html files, are served up directly by IIS and so it is bypassing your security.

You can force static files to go through the ASP.NET pipeline by adding a handler for them under the <system.webServer> section of your web.config:

<handlers>
    <add name="HTMLHandler" type="System.Web.StaticFileHandler" path="*.html" verb="GET"  />
</handlers>

这篇关于拒绝访问HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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