简体   繁体   中英

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

the following web.config 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM