开发者

Control Website Folder Access using Web.config and session variable?

the following web.conf开发者_Go百科ig file is placed in a specific sub-folder on a website. It will allow the user John.Doe to access the pages inside the folder but will deny anonymous users

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
    <authorization>
        <allow users="John.Doe" />
        <deny users="?" />
    </authorization>
</system.web>
</configuration>

Is it possible to replace users in the following web.config file with certain session variable

for example getting the day(sunday, monday, etc) from date and storing it in session("DayVar") then the code should be something like this for the subfolder monday

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
    <authorization>
        <allow session("DayVar")="monday" />
        <deny session("DayVar")<>"monday"/>
    </authorization>
</system.web>
</configuration>

is this doable ?


This is not something that is built into the framework.

You could handle this via a custom base page or similar to implement that type of restriction.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜