I have folder on which i want to apply security like the current user who is using the site, can access that folder but if he is not currently logged in then he cannot see the content of that folder or files of that folder. I know we can do it in web.config file but i dont know how. Please help me. Thanks in advance.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
If I have understood the question…
You can use location elements in the web.config file, there is a lot of information on the web about that – this gives you a start: HOW TO: Control Authorization Permissions in an ASP.NET Application
You basically have elements like this:
<configuration>
<location path="subdir1">
<system.web>
<authorization>
<allow users ="*" />
</authorization>
</system.web>
</location>
</configuration>
That is saying allow all users to the subdir1, you have a deny element too – information here: authorization Element
Method 2
Create a separate web.config file with permission inside the folder that you need security.
Also have a look at this article about Control Authorization Permissions in an ASP.NET Application
eg.
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0