Error: allowDefinition='MachineToApplication' beyond application level

asp.netVisual Studio-2012

asp.net Problem Overview


I have downloaded the online project in ASP.Net. While running application I get an error

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

What changes should i make in web.config or elsewhere to make this work?

asp.net Solutions


Solution 1 - asp.net

I've just encountered this "delight". It seems to present itself just after I've published a web application in release mode.

The only way to consistently get round the issue that I've found is to follow this checklist:

  1. Clean solution whilst your solution is configured in Release mode.
  2. Clean solution whilst your solution is configured in Debug mode.
  3. Build whilst your solution is configured in Debug mode.

Solution 2 - asp.net

Just come across this post and that was happening to me.
Just Clean the project and the error goes away. (must be a VS2010 bug)

Solution 3 - asp.net

I have just had this problem when building a second version of my website. It didn't happen when I built it the first time.

I have just deleted the bin and obj folders, run a Clean Solution and built it again, this time without any problem.

Solution 4 - asp.net

None. You need to set up the directory you've placed the website as a web application within IIS.

Solution 5 - asp.net

This error occurs when you attempt to open a project as a website. The easiest way to determine if you've created a website or a project is to check your solution folder (i.e. where you saved your code) and see if you have a *.sln file in the root directory, if you do then you've created a project.

Just to add, I encountered this error just now when I attempted to open a project I created a while back by selecting "File", "Open Website" from the Visual Studio menus whereas I should have selected "File", "Open Project" instead. I facepalmed as soon as I realised :)

Solution 6 - asp.net

If you have MVC project with enabled views build, one of the solution is to delete obj folder before build. Add to project file:

<Target Name="BeforeBuild">
    <!-- Remove obj folder -->
    <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
    <!-- Remove bin folder -->
    <RemoveDir Directories="$(BaseOutputPath)" />
</Target>

Here is article: How to remove bin and/or obj folder before the build or deploy

Solution 7 - asp.net

In Visual Studio 2013 I struggled with this for a while and it is pretty much easy to solve just follow what the exceptions says "virtual directory not being configured as an application in IIS"

In my case I had WebService planted inside IIS website so

  1. I opened the website in IIS manager
  2. right clicked the WCF folder
  3. clicked Convert to Application
  4. and then submitted with Ok

WCF is back and running.

Solution 8 - asp.net

The error suggests that the code you are using is expecting a virtual directory to be setup on IIS.

Look up the documentation and add the required virtual directory. It should be a directory that has a web.config in it (not the root directory).

Solution 9 - asp.net

A recent web.config change may be in the wrong web.config file.

A <machineKey...> property had been added to Views/web.config. No matter how many Cleans and Rebuilds the error remained. The fix was to move the property into the root /web.config.

Solution 10 - asp.net

if you ever encounter this error

> 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

SOLUTION
I had the same issue with VS 2012. I resolved this by

  1. Unload your current project
  2. edit your .csproj
  3. Find this <MvcBuildViews>false</MvcBuildViews>
  4. Instead of false change the value to true
  5. Load again your project and you should not have any more this error

If you do have then one solution is to delete the content of the obj folder in the project generated by compiler.

Solution 11 - asp.net

In my case, the problem appeared only after I published the project to the subdirectory. Because of my lack of knowledge, I have placed my web_publish subdirectory inside the web_project directory.

It is clear that the web_publish contains also the same Web.configs that the project contains. However, the web_project does not know that my web_publish should be avoided when searching Web.configs in the nested subdirectories. This way, the Web.configs were duplicated and the error appeared.

The solution was to place my web_publish somewhere else.

Solution 12 - asp.net

In my case there was a "Backup" folder which contained another copy of the whole website in there. This meant another web.config and so the build failed with this error. I deleted the "Backup" folder, did a Clean solution on the Debug and Release builds, and the error disappeared.

Solution 13 - asp.net

In my case,

Solution contains 6 projects, 1 main and 5 sub directories. all the sub directories having web.config.

When running any page within sub directories, I was getting same error.

I removed this line from web.config,

<authentication mode="Windows"/>

that worked for me.

Solution 14 - asp.net

Clean your project Remove the /obj folder (probably using publish and deploy? - there is a bug in it)

Solution 15 - asp.net

My problem was I had accidentally published my webservice to a pre-completed location on a fresh install of VS2010.

I had published to a folder called PreCompiledWeb, and the presence of the web.config I suspect messed it up.

I simply nuked the folder, and refreshed the project.

When double-clicking this error - it took me to that erroneous web.config file, which tipped me off.

Solution 16 - asp.net

It may be the version problem like you download the project of .Net framework 2.0 and want to open it into the VS2008 then you will need to upgrade to the latest version and VS will create the Backup of the folder in same root directory.You will get the answer here.

Solution 17 - asp.net

I had this error when building the solution with Web Deployment Project created into my solution. I resolve the error by deleting the folder where Web Deployment Project is built to. This folder is specified in "Project Folder" attribute of WDP properties

Solution 18 - asp.net

Delete bin and obj folders. Then rebuild the solution.

Solution 19 - asp.net

Apparently there were two web.config files in my solution. I am using MVC4 and there was another config file under Views and i was making the change in the wrong file. Fixed there helped me.

But you can always change the default redirect/route in the global.asax file.

Solution 20 - asp.net

Probably you have a sub asp.net project folder within the project folder which is not configured as virtual directory. Setup the project to run in IIS.

Solution 21 - asp.net

I added to my website publish script. At the end, delete the obj folder from your website folder.

Solution 22 - asp.net

I've this problem more frequent if "true" is enabled in the project file.

  1. Set false

As Jonny says:

  1. Clean solution whilst your solution is configured in Release mode.
  2. Clean solution whilst your solution is configured in Debug mode.
  3. Build whilst your solution is configured in Debug mode.

Solution 23 - asp.net

I had a project that I didn't want to be a web application I wanted it to be a folder. The answer was to delete the web.config file altogether. It only belongs in the root of an application.

Solution 24 - asp.net

If you face this problem while publishing your website or application on some server, the simple solution I used is to convert folder which contains files to web application.

Solution 25 - asp.net

I've got the same problem in VS 2013 after publishing my project in debug mode. The problem has been solved by removing obj/ files

Solution 26 - asp.net

I have a website project.

In my case I had moved the solution file to another path and that cause the problem. I restored it to the previous location and the problem went out.

Solution 27 - asp.net

For any one still looking, my solution was to delete both the bin and obj folders and restart visual studio seems to fix it.

Solution 28 - asp.net

Via Visual Studio, I had published a WCF Service via FTP, to an external server. It worked fine locally, and when publishing to an internal server, but not to the external. The solution was to publish without providing a Site Path (in other words, publish directly to the root of the virtual directory).

I'm not sure why it worked, since I had already tried moving the files to the root via an external FTP Client - among many other attempts, including all listed here. Maybe it was something with the publish profile, like it was for FabianVal. But I'm not in the mood of testing anymore at this point, since I'm in a hurry to get up to speed after all the days wasted on this problem.

Solution 29 - asp.net

tip 1: clean & then rebuild.

tip 2: just close VS and open again.

tip 3: the downloaded project may be inside another sub folder... open the folder which has you .net files.

c:/demo1/demo/ (all files)

You should have to open demo from vs... not demo1.

Solution 30 - asp.net

I tried every solution above, but none of them worked for my problem. (I'm sure there are 1000 solutions to this problem) For my scenario, I was attempting to publish my WCF web service that I had in test into production.

However, I failed to realize that in production we are HTTPS only, meaning we redirect everything to HTTPS. As it turns out, I was pointing to the service via HTTP instead of HTTPS, thus causing the error. The solution in this scenario was to simply to change the address protocol to HTTPS rather than HTTP.

I hope that helps some poor soul out there trying to figure out this problem.

Solution 31 - asp.net

In my case I was hosting with GoDaddy which wasn't the problem but it added a layer of confusion.

I had a root folder "WebServices" and set that as the application root.

HOWEVER the service was in a subfolder called "GeoLocateSpecials" as the "WebServices" folder is a container for many services.

So I had to set GeoLocateSpecials as an application root and it worked great from there.

Hope that helps anyone else out there.

Solution 32 - asp.net

I was having the same issue when I would publish the site, if I build the site I get no issues but while publishing I would get this awful error:

> "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 everything that has been stated here in this post to no resort, what worked for me was to just create a new publish profile with exactly the same as the one I've been using and that works well, don't get the error with the new profile but do with the old. Not sure what the difference is but at least I can publish my MVC project.

Hope this helps somebody!

Solution 33 - asp.net

After deleting Crystal Reports Backup Files from the project folder it is working for me.

Solution 34 - asp.net

In our case, we were deploying a site out to a server which was replicated across other servers. Performing an IISRESET on all servers in the deployment environment worked.

Solution 35 - asp.net

I had the same problem because a new global Web.Config is automatically created for the parent folder. It was \Website\Website.

After I moved all file from the child folder to the parent and delete the child folder, now I have only one Web.Config and the problem is resolved.

Solution 36 - asp.net

Multiple web.config in same project creates this problem, this could haven created inside/due to Area,views folders.

The solution could be to change the main/root web.config settings to:

> Build Action - Content > Copy to Output - Do not Copy

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDeepaliView Question on Stackoverflow
Solution 1 - asp.netJohn ReillyView Answer on Stackoverflow
Solution 2 - asp.netEduardo MolteniView Answer on Stackoverflow
Solution 3 - asp.netxiecsView Answer on Stackoverflow
Solution 4 - asp.netuser1228View Answer on Stackoverflow
Solution 5 - asp.netPeteView Answer on Stackoverflow
Solution 6 - asp.netIgorView Answer on Stackoverflow
Solution 7 - asp.netMarekView Answer on Stackoverflow
Solution 8 - asp.netOdedView Answer on Stackoverflow
Solution 9 - asp.netSushiGuyView Answer on Stackoverflow
Solution 10 - asp.netvisar_uruqiView Answer on Stackoverflow
Solution 11 - asp.netpeprView Answer on Stackoverflow
Solution 12 - asp.netDruidView Answer on Stackoverflow
Solution 13 - asp.netPraveen TiwariView Answer on Stackoverflow
Solution 14 - asp.netNicoJuicyView Answer on Stackoverflow
Solution 15 - asp.netgaijintendoView Answer on Stackoverflow
Solution 16 - asp.netgofor.netView Answer on Stackoverflow
Solution 17 - asp.netIlyaView Answer on Stackoverflow
Solution 18 - asp.netrovsenView Answer on Stackoverflow
Solution 19 - asp.netGautam BeriView Answer on Stackoverflow
Solution 20 - asp.netfunwithcodingView Answer on Stackoverflow
Solution 21 - asp.netValamasView Answer on Stackoverflow
Solution 22 - asp.netRiccardo BassilichiView Answer on Stackoverflow
Solution 23 - asp.netRob SedgwickView Answer on Stackoverflow
Solution 24 - asp.netehabh86View Answer on Stackoverflow
Solution 25 - asp.netGrigory BushuevView Answer on Stackoverflow
Solution 26 - asp.netDaniel SilvaView Answer on Stackoverflow
Solution 27 - asp.netRicky GView Answer on Stackoverflow
Solution 28 - asp.netAske B.View Answer on Stackoverflow
Solution 29 - asp.netLearnerView Answer on Stackoverflow
Solution 30 - asp.netGaffView Answer on Stackoverflow
Solution 31 - asp.netGPGVMView Answer on Stackoverflow
Solution 32 - asp.netFabianValView Answer on Stackoverflow
Solution 33 - asp.netMd. Ilyas Hasan MamunView Answer on Stackoverflow
Solution 34 - asp.netuser1477388View Answer on Stackoverflow
Solution 35 - asp.netAugusteView Answer on Stackoverflow
Solution 36 - asp.netMoumitView Answer on Stackoverflow