Mohamed Kamal
Mohamed Kamal

Reputation: 2352

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 ?

Upvotes: 4

Views: 1081

Answers (1)

Mitchel Sellers
Mitchel Sellers

Reputation: 63126

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.

Upvotes: 1

Related Questions