You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

You may get this error when trying to browse an asp.net application.

The debug information shows that "This error can be caused by a virtual directory not being configured as an application in IIS."

However, this error occurs primarily out of 2 scenarios.

1. When you create an new web application using visual studio.net, it automatically creates the virtual directory and configures it as an application.
However, if you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and
may get the above error. The debug information you get as mentioned above, is applicable to this scenario.

To resolve it, Right Click on the virtual directory - select properties and then click on "Create" next to the "Application" Label and the textbox. It will
automatically create the "application" using the virtual directory's name. Now the application can be accessed.


2. When you have sub-directories in your application, you can have web.config file for the sub-directory. However, there are certain properties which cannot
be set in the web.config of the sub-directory such as authentication, session state (you may see that the error message shows the line number where the
authentication or sessionstate is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level
unless the sub-directory is also configured as an application (as mentioned in the above point).

Mostly we have the practice of adding web.config in the sub-directory if we want to protect access to the sub-directory files (say, the directory is admin and we
wish to protect the admin pages from unathorized users).

But actually, this can be achieved in the web.config at the application's root level itself, by specifing the location path tags and authorization, as follows:-

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

However, if you wish to have a web.config at the sub-directory level and protect the sub-directory, you can just specify the Authorization mode as follows:-

<configuration>
<system.web>
<authorization>
<allow roles="administrators" />
<deny users="*" />
</authorization>
</system.web>
</configuration>

Thus you can protect the sub-directory from unauthorized access.

Cheers.

posted @ Monday, April 25, 2005 7:48 AM

Print

Comments on this entry:

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by Jayant Apte at 9/14/2005 6:44 AM
Gravatar
Hi,
This helps me solve my problem. Thanks

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by myChucky at 5/19/2006 10:51 AM
Gravatar
Very nice thread. I have the exact problem. However, this thread does not mention about how to verify if there is a virtual directory created by visual studio. In situaion it seemed that VS didn't create a virtual directory and that has caused a lot of problems. How do I get VS to create them and set it to Application? I have gone to the ASP.NET website forum but it seemed they were clueless about this issue. No one has answered my question yet. So I hope someone in here will answer this question for me. Many thanks in advance.

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by KJH at 5/19/2006 7:10 PM
Gravatar
Thank! Helped me.

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by prem at 8/3/2006 3:01 AM
Gravatar
hi it really helped me to solve my problem thanQ

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by Umair Khan at 8/20/2006 8:13 AM
Gravatar
Nice Work!
What if we remove the authentication in the web.config file.
<!-- <authentication mode="Windows"/>-->
What will be the effect on the Authentication then ?

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by Renum at 10/7/2006 12:39 AM
Gravatar
Thanks alot this every other site, just mentions #1. My problem was #2...

Thanks again..

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by ed at 12/20/2006 4:02 PM
Gravatar
Thanks a lot. Your explanation in #2 solved my problem!

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by Helen at 2/13/2007 2:59 PM
Gravatar
In authentication error, will the code you suggested replace <!-- <authentication mode="Windows"/>-->? If not, just where should the code be placed, before or after this line?

Thanks!

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by Kimage at 3/16/2007 1:29 PM
Gravatar
I'm having a problem with my web.config with virtual directories
My problem is at the configurationstrings node.
I have a running 2.0 site and i want to configure anoter site as virtual directy under this site
like this
|Site A (2.0)
|-Projects (virtual directory)
|-|- Site B (2.0)

What is my problem?
In Both sites I use a ddl for my datalayer.
In the webconfig of site A I set the connectionstring of this ddl to the correct database A.
site A web.config:
<connectionStrings>
<add name="company.configuration.SQLConnection" connectionString="correct datasource to database A" />
</connectionStrings>

I do the same for site B (same name, except to database B)
I first clear the connectionstring and even do a remove!
<connectionStrings>
<clear/>
<remove name="company.configuarion.SQLConnection"/>
<add name="company.configuarion.SQLConnection" connectionString="correct datasource to database B" />
</connectionStrings>

as I run my website A at location www.siteA.com, there is no problem.
As I run website B at location www.siteA.com/projects/siteB he is still getting the values from database A (even I have updated this in the webconfig)

How can I solve this so that for Site B he accually takes the values from the connectionstring B

Thanks in advance

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by cdm at 9/7/2007 10:00 PM
Gravatar
Hi,

Thanks for your valuable research and display here.

I was scratching my head to resolve this problem. Fortunately I found this and rectified my problems.

An Indian

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by Sander at 10/19/2007 9:16 AM
Gravatar
/me slaps his head

Thanks! Scenario number 2 for me.

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by Dave at 11/24/2007 6:25 AM
Gravatar
Nice article. Sadly I still have the problem - am using IIS7 though. Oh, I long for Apache!

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by Cristina at 1/20/2008 5:22 AM
Gravatar
Thanks! No. 2 worked for me :-)

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by Jats at 1/21/2008 9:59 PM
Gravatar
Hi none of the solutions helped me.

In my case, I had a fully working application and later i had coppied the application to another folder as root....
Root <New Folder>
--> Application Folder
-- Files with in the folder

After copping the application folder to New root Folder, this error is bieng displayed. In fact if i am rt. clicking Root folder directory a Property page is oppening where i am not able to find
Right Click on the virtual directory - select properties and then click on "Create" next to the "Application" Label and the textbox.

Can you give me any solution for this...

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by Joe at 3/26/2008 11:30 AM
Gravatar
You are absolutely right. thanks a lot. It's every useful.

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by Lokesh at 4/10/2008 10:05 PM
Gravatar
I was wondering how to resolve this problem, then i got through your thread, it saved my time

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by H-Bomb at 4/17/2008 4:09 AM
Gravatar
Totally solved my problem - Thanks so much for an well-written, easy to follow article!

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by Kathir U at 4/18/2008 10:57 PM
Gravatar
your help was great. I have been looking for this solution for two days.

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by tom at 5/20/2008 3:27 AM
Gravatar
thanks for the post. helped me figure out what this error meant.

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by laurentiu at 6/13/2008 1:33 AM
Gravatar
Thank you, it helped me solve my problem!

If only MS would have such support level...

# allowDefinition='MachineToApplication' beyond application level" in asp.net

Left by Bill at 8/4/2008 1:16 AM
Gravatar
Well, neither scenario works for me. I moved my project over to a new machine. Set up the virtual directories but to no avail. I get the same error. When I start without debugging, the app dies on the authentication = windows line in the webconfig. I thought I could move a project to a new machine, set up a virtual directory, and debug. No such luck. Any insight?

# re: You may receive the error "It is an error to use a section registered as allowDefinition

Left by Derek Hosewood at 9/7/2008 8:49 PM
Gravatar
thanks for this. solved my problems when trying to recreate my sites on a new server.

now i'm up and running again.

Thanks

# re: You may

Left by Derek Hosewood at 9/7/2008 8:50 PM
Gravatar
thanks again
quick loans

# Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application le

Left by RAHUL at 2/22/2009 4:35 PM
Gravatar
NOT FOUND THE OPTION "CREATE" WHILE RIGHT CLICKING-> SELECT PROPERTIES-> "Create" next to the "Application" Label and the textbox

# That's quite nice

Left by Casinoregel at 4/2/2009 6:15 PM
Gravatar
I created virtual directory and mapped to application.Then am trying to build the application, am getting this error message.
"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. "

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by bern at 6/7/2009 5:38 AM
Gravatar
<authorization>
<allow roles="administrators" />
<deny users="*" />
</authorization>

What do I put in the "administrators"?

# re: You may receive the error "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond appli

Left by Muruganantham Durairaj at 6/13/2009 12:38 PM
Gravatar
Just today faced this issue. Timely got this solution.

Thanks.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345