如何才允许用户属于角色才能访问文件夹中的文件? [英] How Can i allow users belongs to role only to access files in folder?
本文介绍了如何才允许用户属于角色才能访问文件夹中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have a website that Contains pdf files stored in folder on server and i need to set access to this files in folder only for users that logged in and belong to role i choose! thanks for helping :) :)
Explain the situation: name of folder is "files" name of a file in folder is "f.pdf" when i type this url "www.website.com/files/f.pdf" it's open pdf file that suppose open only for authenticated users?? how can i solve this problem ??
推荐答案
如果其他人对此答案的解决方案感兴趣,Mike Brind回答了这个主题:我如何才允许用户只属于角色才能访问文件夹中的文件? [ ^ ]。
In case something else is interested to the solution of this answer, Mike Brind answered to this thread: How Can i allow users belongs to role only to access files in folder?[^].
在web.config中添加此代码
Add this code in your web.config
<location path="files">
<system.web>
<authorization>
<deny users="?" />
<allow roles="RoleToAllow" />
</authorization>
</system.web>
</location>
参考此链接
ASP.NET授权
这篇关于如何才允许用户属于角色才能访问文件夹中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文