prevent文件浏览 [英] Prevent file browsing

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

问题描述

我有两个问题如下:

首先,我提供的文件下载功能给用户,但是当用户复制URL,然后在另一个浏览器粘贴,我不想下载上手的开始,而不是我想只有当用户从导航这是开始链接应用程序。

First,I provided the file download functionality to the user, but when user copies the URL and paste in another browser, I do not want the download to get started start, instead I want this to be started only when user navigates from link in the application.

二如何prevent文件浏览在asp.net?我试过

Second how to prevent file browsing in asp.net? I tried

<directoryBrowse enabled="false"/>

在web.config中。但没有用。

in web.config. but was not useful.

推荐答案

得到了解决,

选项1.you可以在web.config文件添加到该文件要限制访问存在,并添加以下行到web.config中的目录

Option 1.you can add the web.config file to the directory in which the file you want to restrict the access exist and add following lines to the web.config

<configuration>
  <system.web>
   <authorization>
    <deny users="?"/>
   </authorization>
  </system.web>
</configuration>  

选项2.您可以添加以下行到现有的根web.config。

Option 2. You can add following lines to the existing root web.config.

<configuration>
<location path="DirectoryName">
    <system.web>
        <authorization>
            <deny users="?"/> <!-- Denies Anonymous Users -->
        </authorization>
    </system.web>
</location>
</configuration>

这篇关于prevent文件浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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