Accessing a management website folder using Web.config and a session variable?

The following web.config file is placed in a specific subfolder of the website. This will allow the user John.Doe to access the pages inside the folder, but will prohibit 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 a specific session variable

for example, to receive the day (Sunday, Monday, etc.) from the date and store it in the session ("DayVar"), then the code should be something like this for Monday subfolder

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

is it doable?

+4
source share
1 answer

This is not what is built into the framework.

You can handle this with a custom base page or similar implementation of this type of constraint.

+1
source

Source: https://habr.com/ru/post/1337365/


All Articles