ASP.NET MVC error: It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level
Error 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, solution is here.
How to reproduce
This is what I have to do to get this error in Visual Studio:
- Enable building of views in project file
- Switch to release mode
- Build and publish application
- Switch to debug mode
- Run application
What I understood when looking for solution to this issue is that it comes when building of views is enabled.
Solution
Before doing anything else try out working solution by Igor Kitsula. Although it is written for Visual Studio 2013 it works also with newer version (I have Visual Studio 2017). In short, this is solution.
- Unload problematic project in Visual Studio
- Open project file and go to end of 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 project and run it
Although most of my new projects are on ASP.NET Core I will leave this peace of information here for records.
Pingback:Dew Drop - July 12, 2018 (#2764) - Morning Dew
String repeat method concept ,I easly understand by ur explain it is to understand ,the difference between methods used in C# program ,while we always go through forloop by ur concept it’s clear that less time to execute the method
Thank you very much