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

StackOverflow https://stackoverflow.com/questions/20107593

Question

Getting this error on an intranet application we have running in our development environment, and I'm not sure where to go/look for a solution. The application used to work fine, however it is run on a shared server with another team of developers and we're having trouble tracking down the error (no updates were made to the application by my team, it suddenly stopped working).

We're running Windows Server 2003 and IIS 6.0. If I open the solution on my machine, however, I receive an error in Visual Studio solution points to this line in the web.config, however I believe this is a relatively standard setting and we actually have this running in another environment (same server/IIS set up)

<authentication mode="Windows" />

The error reads

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've also changed the <system.web> section of the web.config on the server to include <customErrors mode="Off"/>, however oddly enough when I navigate to the site I am still getting the custom error page...

I'm relatively new to IIS and never worked with Windows Server 2003. Can someone help point me in the right direction either to get the actual error so display in the browser or how to fix the error given to me by Visual Studio?

Was it helpful?

Solution

Bring up project properties page in Visual Studio. Right-click on project node in Solution Explorer and click properties. Look for the Web tab and click the button to create a virtual directory.

OTHER TIPS

In some cases this could be caused by creating another sub-folder in your project and you added another Web.config file which has the same filename as the other Web.config file in the root folder.

To resolve this error, rename your newly added Web.config file to another name.

enter image description here

In my case inside my web directory, I had an other web directory along with its own web.config file. When I removed that sub directory that was a complete website in its own my problem is fixed now.

Just had this issue ... turned out to be a result of allowing debug information to be produced when publishing the Web App.

Publish Web App - Settings - File Publish Options - Precompile during publishing (true) - Configure - Emit debug information. (Should actually read "Omit debug information")

Delete Debug subdirectory of project and republish

This can also happen when you create a publish folderprofile if you take the default location, which is app.publish folder under your project folder. VS then gets confused and thinks there's another web.config it has to reconcile when building. Why does microsoft allow you to shoot yourself in the foot like this? Moving the Publish FolderProfile to another location stops the error from occuring.

any how web.config should be in the root directory most probably it happens when you don't have the solution file for your project. Close VS open it once again and choose the direct folder. Note web.config file should be in root directory or if you want to in sub directory then copy the webconfig file and create a new config file in the root. Caution:if you have mentioned any path in config file that will be lost

I had this problem. I think I caused it to start happening by modifying some settings in the publish profile. Undoing those settings fixed my issue. Here's what I did:

  • Right click on the project and go to publish
  • In the publish tab, in the configuration row, click "configure"
  • go to the settings tab
  • expand File Publish Options
  • I unchecked all of the options that were there. (checking some of these is what i believe caused my problem in the first place)
  • I deleted the bin and obj folders in my publish directory.

I have VS2017

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top