Is it possible for the location authorization nodes in web.config to be external?

Is it possible for the location authorization nodes in web.config to be external?

So that I can take all the nodes similar to

  <location path="elmah.axd">
    <system.web>
      <authorization>
        <allow roles="Administrator" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>      
  <location path="Admin">
    <system.web>
      <authorization>
        <allow roles="Administrator, Representative" />
        <deny users="*" />
      </authorization>
    </system.web>
  </location>

And move them outside of web.config or something like that? I find these nodes in extreme amounts of noise for web.config when they are relatively static. Usually my approach was to configure the source for something like this, but since it falls under the root of the node, I'm not sure if this is possible with these nodes.

+3
source share
1 answer

you can create web.config inside each folder with the appropriate security settings, all named web configurations.

  • ~ / members / web.config
  • ~ / Members / vip / web.config

as:

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <system.web>
    <authorization>
        <allow roles="developers" />
        <allow roles="testers" />
        <deny users="*" />
    </authorization>
   </system.web>
</configuration>

web.config, (, , ) " " .

+2

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


All Articles