ASP.NET MVC Error
If you've seen this error - 'It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level' - the solution is here.
Join the DZone community and get the full member experience.
Join For FreeError when running ASP.NET MVC application from Visual Studio: "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." Stop inventing painful hacks, the solution is here.
How to Reproduce This Error
This is what I have to do to get this error in Visual Studio:
- Enable the building of views in a project file.
- Switch to release mode.
- Build and publish the application.
- Switch to debug mode.
- Run the application.
What I understood when looking for a solution to this issue is that it comes about when the building of views is enabled.
Solution
Before we doing anything else, let's try out a working solution by Igor Kitsula. Although it is written for Visual Studio 2013, it also works with newer versions (I have Visual Studio 2017). In short, this is the solution.
- Unload the problematic project in Visual Studio.
- Open the project file and go to the end of the file.
- Paste the following block of XML:
<Target Name="BeforeBuild"> <!-- Remove obj folder --> <RemoveDir Directories="$(BaseIntermediateOutputPath)" /> <!-- Remove bin folder --> <RemoveDir Directories="$(BaseOutputPath)" /> </Target>
- Save project file and close it
- Reload the project and run it.
Although most of my new projects are on ASP.NET Core, I will leave this piece of information here for the record.
Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
An Overview of Kubernetes Security Projects at KubeCon Europe 2023
-
Extending Java APIs: Add Missing Features Without the Hassle
-
What Is Istio Service Mesh?
-
Working on an Unfamiliar Codebase
Comments