用户应该无法下载文件 [英] User should not able to download file
问题描述
亲爱的朋友,
我在网络服务器上有多个扩展名不同的文件(例如.doc,.xls,.pdf,.mp3,.zip ....).
现在,我希望如果用户访问链接中的文件名,那么除了已登录的用户外,不应下载该文件.
例如,
文件名为"myfiles.zip"
链接是http://www.mysite.com/myfiles.zip
因此,如果最终用户直接访问http://www.mysite.com/myfiles.zip,则不应下载.
但是,如果用户已登录该应用程序,则应下载该文件.
如何在ASP.Net 2.0和SQL 2005中使用?
请帮助我解决以上问题.
提前谢谢.
:-)
Rohit
Hi Dear Friends,
I have multiple files on web-server with different extension (e.g., .doc, .xls, .pdf, .mp3, .zip....).
Now, I want that if user access file name in link then that file should not be download, except the logged in user.
Example,
file name is "myfiles.zip"
link is http://www.mysite.com/myfiles.zip
So, if end user direct access http://www.mysite.com/myfiles.zip, then it should not download.
But if user is logged in the application then that file should download.
How to use in ASP.Net 2.0 and SQL 2005 ?
Please HELP me to resolve above issue.
Thanks in advance.
:-)
Rohit
推荐答案
hi,
Put your files (those you dont want to directly accesssible) under downloadfiles folder.
on web config put the codes given below,
<location path="downloadfiles">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
This section should be placed out side <system.web> section
Target file will download if user login.
Hope this will help
这篇关于用户应该无法下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!