如何限制图像文件夹的直接访问 [英] how to restrict image folder from direct access

查看:85
本文介绍了如何限制图像文件夹的直接访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个图片网站,会员可以在其中上传文件,并限制几个朋友的访问.问题是,可以直接从浏览器访问图像.

请注意,
Neeraj

Hi All,
I''ve a image gallery website where members can upload and restrict the access to few friends. The problem is, images are directly accessible from browser. How could I restrict specific folder to accessible from aspx pages only.

Regards,
Neeraj

推荐答案

Neeraj Arora写道:
Neeraj Arora wrote:

如何限制特定文件夹只能从aspx页面访问

How could I restrict specific folder to accessible from aspx pages only



编写一个处理图像请求的http处理程序.检查身份验证并显示必要的消息.确保在IIS设置中将扩展映射到ASP.NET.



Write a http handler which handles requests for images. Check the authentication and display necessary messages. Make sure you map the extensions to ASP.NET in IIS settings.


有两种方法-一种简单的"hack"方法和一种适当"的方法...

简单的方法很简单使用无法猜测的随机分配(GUID类型的东西)文件名保存图像.一旦知道了文件名,这并不会阻止人们直接链接到您的图像,但是除非您的图像非常受欢迎,否则这不太可能会出现问题,但这会阻止他们查找图像,直到您揭示地址为止. br>
正确的方法是编写自定义处理程序;您可以在此处 [
There are two ways of doing this - an easy "hack" and a "proper" way...

The easy way is simply to save your images with randomly assigned (GUID-type thing) filenames which can''t be guessed. This doesn''t stop people linking directly to your images once they know the filename of course, but unless your images are highly popular that is unlikely to be a problem, but it will stop them from finding images until you reveal the address.

The proper way is to write a custom handler; you can find an example here[^]. Note though that depending on your version of IIS you may need to perform some steps differently - that article assumes IIS6; once you get above this you need to write your config file differntly, for one thing...


答案2很好,但是如果我们将其部署到真实服务器上会发生什么...可以我们仍然允许在真实主机上重新配置IIS....
第三个答案是使用ASHX处理程序.
检查下面的链接
http://aspalliance.com/1322_Displaying_Images_in_ASPNET_Using_HttpHandlers.all#top
Answer 2 is good, but what happen if we deploy it to real server...Can we still enable to reconfig the IIS at real host....
The third answer is using ASHX handler.
Check the link below
http://aspalliance.com/1322_Displaying_Images_in_ASPNET_Using_HttpHandlers.all#top


这篇关于如何限制图像文件夹的直接访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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