如何prevent访问未经授权的用户在主机.pdf文件资源这样? [英] How to prevent accessing unauthorized user to resource such as .pdf file in host?

查看:164
本文介绍了如何prevent访问未经授权的用户在主机.pdf文件资源这样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.NET Web应用程序的那一刻,我有一些资源,例如在主机部分.pdf文件或图片中的特定文件夹。
如果任何用户知道这些文件的URL可以从浏览器访问它们,我怎么能管理访问或禁止从这些文件匿名用户?

At the moment in my ASP.NET webApp I have some resources such as some .pdf files or pictures in specific folder in the host . If any user know the URL of those files can access them from the browser , How can i manage access or ban anonymous user from those files ?

推荐答案

您可以使用的地点在web.config中的指令。

You can use the location directive in web.config.

<location path="resources">
    <system.web>
            <authorization>
                    <allow roles="Customers"/>
                    <deny users="*"/>
            </authorization>
    </system.web>
</location>

这样你就可以把你的资源(PDF格式,图像)目录中的资源。
只有客户将能够向他们展示。
请注意,他们仍然可以下载文件,上传到另一台服务器,但我想你已经知道了。

This way you can put your resources (pdf, images) in the directory "resources". Only Customers will be able to show them. Note that they can still download the files and upload it to other server, but I guess you already know that.

这篇关于如何prevent访问未经授权的用户在主机.pdf文件资源这样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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