2


i was trying to find out how can i use only root web.config instead of each one in any sub-folders of a ASP.NET Webforms project on the internet, but unfortunately i could not find propper answer. for example we have a project that has sub-folders like Administrator or Users and in the each one we have Web.Config files that authenticate users and restrict users by their permission.
With this mentioned issue, is it possible that we use ONLY a root web.config to authenticate users without any web.config in sub-folders?


Please help me.

Shadman

Aspmaker
  • 25
  • 5

2 Answers2

0

You can use location element
example

<location path="subdir1">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
</location>
Emin Hasanov
  • 1,299
  • 1
  • 13
  • 29
  • Thank you eminach, I know that we can use `location` tag in web.config in order to make permision for users, but it can be used on the web.config files that exist in sub-folders! When i put this tag on root web.config i got error from IIS. – Aspmaker Aug 17 '13 at 07:49
  • Put non exist yet folders into major-floder and give permissions to all child folders – Emin Hasanov Aug 17 '13 at 07:55
  • I didn't understand eminach, could you explain it please? or give me a help or reference about this? Thanks. – Aspmaker Aug 17 '13 at 08:17
0

You cannot combine <location> and <authorization> tags in a web.config file. You need to have config files for your sub-directories as well, or there is a workaround for a single config file that adds code to your aspx and code-behind files.

Web.config allow location access for specific user

Community
  • 1
  • 1
Chris Schiffhauer
  • 17,102
  • 15
  • 79
  • 88