Home > Back-end >  Visual Studio 2019 - Error ASPCONFIG: It is an error to use a section registered as allowDefinition=
Visual Studio 2019 - Error ASPCONFIG: It is an error to use a section registered as allowDefinition=

Time:01-05

I'm trying to publish a website in Visual Studio 2019. Publishing to a folder is successful with default settings but when I check Precompile during publishing option, I get following error while publishing the website.

C:\<User Dir>\AppData\Local\Temp\WebSitePublish\MyWebSite--144316003\obj\Debug\AspnetCompileMerge\Source\bin\release\publish\web.config(167,0):Error ASPCONFIG: 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 tried following solutions which I found on similar questions:

  • Clear solution and Build solution
  • Rebuild Solution
  • Delete obj/Debug and obj/Release folder
  • Delete publish profile and create new one
  • Following the same steps again after opening Visual Studio in Admin mode

Also, this so post suggested that the problem might be with Microsoft.Net.Compilers. But when I search for this installed nuget package, I can't find it. Can someone please suggest on this what's causing this issue and how can it be resolved?

Update: Upon trying different Publish settings, I came to know this error occurs only when Precompile during publishing option is checked.

CodePudding user response:

I was able to publish the same website in target folder by cloning it again at a new location.

I built the newly cloned project in release mode and published it with Precompile during publishing enabled and it did not throw any error.

  •  Tags:  
  • Related