23

I get the following error when I try to compile an asp.net site using a custom build script.

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.

Although the description is in detail I do not understand what it means exactly. I have not configured IIS to host this website and I don't think I will be able to as I am running Vista Home Basic version. So the website cannot be built using custom scripts?Please reply as I want to test this feature.

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
kjayakum
  • 1,205
  • 3
  • 14
  • 15
  • possible duplicate of [allowDefinition='MachineToApplication' msbuild error](http://stackoverflow.com/questions/5271320/allowdefinition-machinetoapplication-msbuild-error) – Flexo Nov 17 '11 at 10:31
  • I too was deleting the obj folder until I had a conflict with a build script which required it. Catch-22, I used the accepted answer on the following SO link to move the location of the Obj folder to C:\Temp\BUILD. You have to do it per csproj file, but it is a great solution. Here is the link: http://stackoverflow.com/questions/261422/visualstudio-how-to-save-the-obj-folder-somewhere-else – Valamas Nov 17 '11 at 05:51

5 Answers5

48

I had this SAME EXACT problem and finally discovered a rogue Web.config was placed in my obj folder ... do yourself a favor and do a search in all the sub-directories for a web.config file. I deleted it and all was back to normal.

Jason Wicker
  • 3,416
  • 2
  • 25
  • 32
  • 4
    Thanks, that did the solved the problem for me.I had the same problem. I deleted the object\debug folder and it worked again. – Michael Wells Sep 18 '10 at 14:00
  • 4
    +1 - Nice, thanks. Another note, if you create the backup folder within your project when converting, you will need to remove/rename the web.config there too. – Kyle Rosendo Apr 21 '11 at 05:44
  • 1
    thanks! this was driving me crazy for hours. my stray web.config was in the /views folder. *sigh* – Patricia Aug 15 '11 at 16:12
  • 4
    @Patricia that's normal for ASP.NET MVC - it's more likely a web.config in the obj folder created by doing a Publish – Daniel O Oct 27 '11 at 01:43
  • 1
    @DanielO -- I tried to upvote your comment, as it is precisely the problem I had. Publish was indeed the source of the problem. – Jim Raden Dec 09 '11 at 16:37
  • Thanks! I also managed to find one in my bin\ folder, as it was indicated in the csproj file as the OutputPath. – ThisGuyKnowsCode Feb 14 '12 at 04:41
  • Had the same problem. Did this :) `for /F %i in ('dir obj /s /b') do del /s /q %i` – jamiebarrow Mar 26 '13 at 01:03
  • I only received this error when scanning with HP Fortify. The fix worked. – Keith Walton Nov 23 '15 at 21:49
  • Thanks! This was driving me nuts all week. Turns out it happened when I optimistically switched to VS 2017 for a few days. Back to 2015 now and extremely wary. – immutabl Aug 04 '17 at 11:33
15

The rogue web.config file in the obj folder is most likely to be caused when you do a Publish Web Site. So just clean it up after you've done the publish.

Daniel O
  • 2,810
  • 3
  • 28
  • 35
5

if this happens after the virtual-directory is already created do the following:

  • right-click on web.config
    • properties
      • Build Action: Content
      • Copy to Output directory: Do not copy
  • if transformed (apply to all configurations)
    • properties
      • Build Action: None
      • Copy to Output directory: Do not copy
Nekresh
  • 2,948
  • 23
  • 28
mg3
  • 121
  • 1
  • 5
4

It is likely that your web.config file is placed in a directory that is not the root of the application. On most versions of IIS, you can convert any folder on your web site to an application root:

  1. Open IIS and navigate to the appropriate folder
  2. Right-click on the folder, select properties
  3. Under Application Settings, and beside Application name, click Create
  4. Apply and close

If this does not fix your problem, there may be another configuration error, either with IIS or your application.

Karmic Coder
  • 17,569
  • 6
  • 32
  • 42
0

In IIS, go to the folder that the app runs under, right click it, go to properties. On the Directory tab, look for "Application settings". Click the create button.

Dave Harding
  • 1,280
  • 2
  • 16
  • 31