0

I am getting the below error every time I build my project using IIS Express:

"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."

If I go into the Web Debug Properties and click "Create Virtual Directory" it will let me build it one time, and then it will work. However, I have to do this before building every time.

Also, when I try to publish, it errors out with the same error as well, but the above work-around doesn't resolve it.

hyphen
  • 2,368
  • 5
  • 28
  • 59
  • are you using IIS express, or a full web site that that you can configure a virtual directory? How to create a virtual directory for IIS is outlined here: https://stackoverflow.com/questions/32694217/visual-studio-2015-adding-virtual-directory-not-possible – Albert D. Kallal Jan 24 '21 at 08:27

1 Answers1

0

There are many reasons for this error, you can try the following methods to solve the problem:

1.restart of Visual Studio and try again.

2.Deleting the OBJ folder(\myWebApp\obj).

3.Click on the Web.config file from Solution explorer and right click "Properties" and change to "Copy to Output Directory: Do not copy".

enter image description here

4.Clean solution whilst your solution is configured in Debug/Release mode.

samwu
  • 3,857
  • 3
  • 11
  • 25