且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何限制用户访问Asp.net中的XML或图像

更新时间:2023-12-02 15:26:52

您好,



您可以添加
Hello,

You can add
<authorization />

到根web.config,例如:

to the root web.config, like:

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



或者您可以使用以下内容将web.config添加到要允许/拒绝访问的文件夹中:


or you can add a web.config to the folder where you want to allow/deny access with the following content:

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



当然要替换


Of course replace the

<allow />

<deny />

拥有自己的规则;)