Restricting file access to certain users

可紊 提交于 2019-12-13 04:42:09

问题


I have a site, into which users log in using forms authentication, in which I want to restrict access to files in a particular folder to certain users.

So, for instance, folder dir/foo will be accessible to user1 but not user2 or user3 and folder dir/bar will be accessible to user2 but not user1 or user3.

How can I do this?


回答1:


User roles then setup the locations in web.config

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

OR for each folder created add a new web.config to folder root

<?xml version="1.0"?>
<configuration>
    <system.web>
        <authorization>
            <allow roles="folderUsers"/>
            <deny users="*" />              
        </authorization>
    </system.web>
</configuration>



回答2:


check the <location> element of web.config



来源:https://stackoverflow.com/questions/10738673/restricting-file-access-to-certain-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!