goalie35
goalie35

Reputation: 786

Error in web.config "location"

My site has 2 logins. 1 on the front end for regular users, and one in the admin section, for admins (I need 2 logins because each one asks for different login criteria). To authenticate the admin directory, I setup a "location" element in my main site's web.config like this:

<location path="Admin">
<system.web>
  <authentication mode="Forms" >
    <forms loginUrl="/Accounts/adminLogin.aspx"/>
  </authentication>
  <authorization>
    <deny users="?"/>
  </authorization>
</system.web>

If I try to type any page from my "Admin" directory, into my browser, I get the following error:

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.

How can I setup my location element to redirect properly?

Thanks

Upvotes: 3

Views: 1423

Answers (2)

Sakthivel
Sakthivel

Reputation: 1938

There are mainly one of the two reason why you got this error message.

  1. If you have not configured your asp.Net application in iis. If you have not configure your application to run on iis first configure your site to run on iis.For that create virtual directory from iis and give permission to application (read,write)
  2. If above is not problem then there are mainly problem of two or many web.Config exists on your site.When you open some site and if software crate backup of that application then software mainly do create subfolder and copy all files + web.Config in application.Just remove this subfolder web.Config from subfolder.

Check the web.Config in your admin folder and main root folder for settings and configurations.

Upvotes: 1

Huseyin Yagli
Huseyin Yagli

Reputation: 10295

You can't change the Authentication mode within a subdirectory. Only WebApplications can define this setting which applies to the entire application. A location element is only used in subdirectories to change authorization, not authentication settings.

Upvotes: 0

Related Questions