0

I am trying to grant access to anyone to a specific page in IIS. I have main folder with the .NET Framework website in C# in this folder I have Web.config file which has

<authentication mode="Windows">
</authentication>

</system.web>
    <authorization>
        <deny users="?" />
        <deny users="*" />
        <allow roles="MySpecial Group" />
    </authorization>
</system.web>

Also in this folder I have another folder with a page that I want to be accessible to anyone who does not belong to this group. Can someone please help me how to configure this Web.config file or how do I configure one inside my folder's page to make it accessible.

main site
|__Web.config      //this is the main Web config with deny-all allow-mygroup
|__index.asp
|__my special page   //this is the folder I want to be accessible to anyone 
|  |__default.aspx
|  |__default.aspx.cs
|  |__Web.config
|__page2
|__page3

if user is not in group goes to main site it will show no access, and if user goes to main site/my special page it should work. I am using Windows Authentication in an intranet website

EDIT: Figured out with help @Lex Li I was missing just one thing, in main Web.config deny and allow rules are overwriting from top to bottom so i had to add the location path that needs another permission before the global permissions

<location path="my special page">
    <system.web>
        <authorization>
            <allow users="?" /> <!-- This will overwrite bottom rules -->
        </authorization>
    </system.web>
</location>

<authentication mode="Windows">
</authentication>

</system.web>
    <authorization>
        <allow roles="MySpecial Group" /> <!-- This needs to be on top over next deny rules, otherwise this will have no effect -->
        <deny users="?" />
        <deny users="*" />
    </authorization>
</system.web>
3
  • 1
    If you want to change settings for a folder, add a web.config in that folder is the right way to go. An alternative is to use a location tag in the parent folder's web.config. If you just want to change settings of a single file, then a location tag is the only way to go. Tons of examples over the internet, but maybe this is the first time you hear about location tags.
    – Lex Li
    Apr 30, 2020 at 22:32
  • @LexLi Thank you for help I figured it out and updated with new code
    – Nicolae
    May 1, 2020 at 20:02
  • If you figured out the solution, you should post your answer and then accept it below.
    – Lex Li
    May 1, 2020 at 21:27

0

You must log in to answer this question.

Browse other questions tagged .