It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.
The top line in all of my aspx pages in my /portal/ directory has this error message, and I know it's a common one. I have googled this error message to no end, and I see a lot of posts telling me to configure the /portal/ folder as an application in IIS (which I have), and more posts telling me I have nested web.configs (but none of the postings offer guidance toward a solution).
My setup is that I have a web.config in my root directory, and then I'm trying to make a company portal, in the /portal/directory. The /portal/ directory has its own (necessary) web.config.
My web.config line 50 is like this:
<customErrors mode="Off" defaultRedirect="customerrorpage.aspx"/>
<anonymousIdentification enabled="true"/>
<authentication mode="Forms"/>
<membership defaultProvider="MyProvider">
So I have domain.com/web.config AND domain.com/portal/web.config ... so my domain.com/portal/default.aspx page will not load.
What is the real solution to this? Do I somehow find a way to merge my root web.config with my /portal/ directory web.config, or am I way off base here?
Any guidance would be greatly appreciated!
"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."
I had this problem in VS.NET. Turned out that when I was configuring some config transforms I had mistakenly set the Web.config file's property "Copy always". I usually set my transform files to "Copy always" but leave the web.config root file as "Do not copy".
Watch out tho, because changing the properties of web.config also changes all the nested transforms.
So, to fix:
1) Change web.config to "Do not copy"
2) Optionally, if you're using config transforms, set them to "Copy always"
3) Delete the obj and bin folders from the solution (these may not be visible so select the project node in Solution Explorer and click the "Show all files" toolbar button.
4) Publish
Worked for me.
For what it's worth, I had received the error, "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level." and ended up resolving it by clearing the \myWebApp\obj\Debug and \myWebApp\obj\Release directories. I also needed to set a default startup page. But, then the app then started up fine. HTH.
I got this error differently than everyone else:
I was migrating from vs2010 with web deployment project to vs2012 and a new web publish profile.
I created a new web publish project in vs2012 to publish to file system (we have a separate installer builder this is a commercial app) and I was publishing to a folder that was inside the existing web project which is linked to IIS.
This caused the error during publish which mystified me at first because I was publishing to file system, not IIS (I thought).
Solution was to change the publish to folder to outside the web project.
Click on the
Web.config
file from Solution explorer and changeCopy to Output Directory = Do not copy
Sometimes, the simple answer is best. I had two web.config files in my project. The one at the main level is where I needed to make the change to deal with my session timeout (which triggered this issue). I had a separate config file in my Razor Views directory, which had settings for Razor and its views. I was adding a section in there (not at the application level!). Without realizing I had two separate web.config files, I tried everything except looking for the obvious.
I had this issue, and resolved by cleaning my solution of old assemblies etc.
from vs: Build > Clean Solution
then Rebuild.