Specific Page/Folder Authorization in web.config

Leave a Comment

The <location> tags sit outside the main <system.web> tag and are nested directly in the base <configuration> tag, as shown here:
<configuration>
  <system.web>
        <!-- other settings -->
  </system.web>
<location path="Secure.aspx">
 <system.web>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</location>
</configuration>

You can more then one <location></location> in web.config file.

Following code restrict anonymous user to access UserArea folder or directory. User must login to access all pages in UserArea folder or directory
 <location path="UserArea">
    <system.web>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
  </location>

Following code restrict anonymous user to access EditUser.aspx page. User must login to access EditUser.aspx page
 <location path="EditUser.aspx">
    <system.web>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
  </location>

0 comments:

Post a Comment