It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level

13,050

Solution 1

I faced same issue when I had a web application inside another web application resulting in two Web.config files.I deleted one and issue was solved. As configuration settings in the child level can override the ones in parent level,this error can occur when you have 2 web.config files one redefining configuration settings that you cannot override such as authentication or session state. Issue happens when you may have authentication / session state set on the lower level web.config and also in higher level web.config

Solution 2

  • There are an enormous amount of information on getting this error in IIS. I have spent hours on issues like this, because, there has never been a CLEAR ANSWER.

    You will hear things like

    It means that if you have an application, you should not configure the MachineToApplication settings in web.config's in the subdirectories.

    All you have to do is set the MachineToApplication settings in your Application's root, and they will be inherited in the subdirectories.

    Solution :

    Configure all MachineToApplication settings in your application's root, and remove all MachineToApplication settings from your application's subdirectories.

    What all of the answers FAIL TO MENTION is that there are a myriad of file permissions, security, etc.. going on with any file in IIS.

    It used to be easier, but with the increase in the proliferation, it is getting much, much more complicated.

    I have one solution which I have used which got my IIS to work-

    1st. Test a simple HTML page in a new Web App. If you can get that to work, then you should be good for the next steps.

    2nd. When you are thinking about the issue that started this, you have a Machine.config file in the E:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG directory for your Framework.

    This is the file that sets the Type of AllowedDefinitions. ( look for that in the config file)either allowDefinition="MachineToApplication" or allowDefinition="Machine"

    When someone says you have to put your web.config in your applications "Root" Folder, depending on how your application is setup, will dictate where to put your web.config.

    To get mine to work, I put it in the E:\Inetpub\wwwroot folder.

    3rd. You will have to test which sections to include in the config root folder, and which ones you can put in your various web "Application" folders.

    4th. This is a work in progress, but I wanted to get this out there while I was working on it and it was fresh in my mind...

    I'll post more later when I iron out more of the issues.

    I plan to post an extremely detailed explanation later on when I decipher all of the cryptic, purposefully undocumented, sometimes misleading, information on the matter of configs, etc. to get IIS running properly.

    ie. I'm tired of hacking around trying to get it to behave properly, but I want to thoroughly test the system out and document, EXACTLY what needs to be done, and why, to get applications up and running quickly...

    Thanks for reading this.

Solution 3

You need to set it as as an application in IIS.

Share:
13,050
Adam
Author by

Adam

Updated on June 05, 2022

Comments

  • Adam
    Adam almost 2 years

    I want to manage two web.config file in a application one for the front-end user and second for the back-end(admin) user.for admin section I have created a folder with name admin in the same website.following settiongs are in the admin/web.config

    when I am trying to run the application I am getting following 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

    Same problem have discussed on below ASP.NET What causes: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application...?

    It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level

    Please give me some suggestion to solve this problem. Thanks in advance

  • Adam
    Adam over 13 years
    I am using IIS 6, how I will do this, can you tell me the steps
  • eglasius
    eglasius over 13 years
    from the top of my head: right click the folder, open the properties and look for an option that says make application or something like that.
  • eglasius
    eglasius over 13 years
    affiliatewiz.com/support/appstartpoint.asp (just searched: iis create application)
  • Diego C.
    Diego C. over 12 years
    That did the trick for me. I removed the "authentication" node on the nested web.config and it worked right away. Thanks!
  • Rolo
    Rolo over 6 years
    I had a few backup subfolders to keep a few files without changes. It seems they were creating a conflict with the main web.config file.
  • Synctrex
    Synctrex about 3 years
    The fact that this post wasn't updated in the 10 years since its creation doesn't bode well despite this error continuing to crop up!