0

I am using VS 2012 , I want to implement folder level user authentication and authorization, i have following folder/files structure.

enter image description here

Following is Admin -> Web.congfig file.

  <system.web>
  <authentication mode="Forms">
    <forms loginUrl="~/login.aspx" timeout="30" defaultUrl="~/default.aspx" cookieless="AutoDetect">
      <credentials passwordFormat="Clear">
        <user name="Admin" password="abc"/>
      </credentials>
    </forms>
  </authentication>


</system.web>
 <location path="~/Admin/Admin.aspx"></location>
  <system.web>
    <authorization>
      <deny users="*"/>
        <allow users="Admin"/>
      </authorization>
  </system.web>

</configuration>

When i compile the application it gives me the following error message.

Error: 1 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. E:\Kjan\Reports\Admin\Web.config 5

Khuram Jan
  • 79
  • 1
  • 4
  • 16

2 Answers2

0

You can not use

<authentication mode="Forms">
<forms loginUrl="~/login.aspx" timeout="30" defaultUrl="~/default.aspx" cookieless="AutoDetect">
  <credentials passwordFormat="Clear">
    <user name="Admin" password="abc"/>
  </credentials>
</forms>

In you inner web.config file.

Use this on root folder and <user name="Admin" password="abc"/> in your inner web.config file.

Some useful links

  1. Multiple/Different authentication settings in web.config

If you are woking on different Areas then MVC

  1. Different authentication mode for different areas
Community
  • 1
  • 1
शेखर
  • 17,412
  • 13
  • 61
  • 117
0

try this select Menu Build->Configuration Manager select Build checkbox

Genish Parvadia
  • 1,437
  • 3
  • 17
  • 30