Error: allowDefinition='MachineToApplication&#

2019-01-01 12:59发布

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?

30条回答
冷夜・残月
2楼-- · 2019-01-01 13:38

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.

查看更多
零度萤火
3楼-- · 2019-01-01 13:38

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

查看更多
爱死公子算了
4楼-- · 2019-01-01 13:42

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

查看更多
余生请多指教
5楼-- · 2019-01-01 13:43

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.

查看更多
墨雨无痕
6楼-- · 2019-01-01 13:45

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

查看更多
一个人的天荒地老
7楼-- · 2019-01-01 13:45

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

查看更多
登录 后发表回答