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.
精彩评论