views:

542

answers:

3

I can run my Asp.Net MVC 2 application without an issue on my local computer. Just Run / Debug.

But if I have already built it, I can't publish it! I have to clean the solution and publish it again. I know this is not system critical, but it's really annoying. "One Click Publish" is not "Clean solution and then One click publish"

The exact error is as follows:

Error 11 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 suspect it's something to do with the Web.Config in the Views folder, but then why only after I build once previously. And just to note, the app works fine once published.

A: 

I had this problem as well, so I created a Pre-Build Event in the project properties to Clean the output directories(${projectPath}\bin,${projectPath}\obj\${ConfigurationName}). On another project I was also getting this error, even with the cleaning event in place. On the second project I was compiling the views as listed in the project file:

<MvcBuildViews>true</MvcBuildViews>

I changed the true to false, and it no longer complained about that error, but still ran correctly. I won't claim I know exactly what was causing the second error, but at least it got me moving forward for the time being.

eppdog
Thanks for that, but I can't really mark the MvcBuildViews as False as it helps fix issues before I deploy.
burnt_hand
+4  A: 

i had the same problem with my MVC apps. it was frustrating because i still wanted my views to be checked, so i didn't want to turn off MvcBuildViews

luckily i came across a post which gave me the answer. keep the MvcBuildViews as true, then you can add the following line underneath in your project file:

<BaseIntermediateOutputPath>[SomeKnownLocationIHaveAccessTo]</BaseIntermediateOutputPath>

And make that folder not in your project's folder. Works for me. It's not a perfect solution, but it's good for the moment. Make sure you remove the package folder (located inside the obj\Debug and/or obj\Release folder) from your project folder otherwise you'll keep getting the error.

FWIW, MS know about this error...

benpage
A: 

I deleted everything out of my obj/Debug folder and it fixed this error. This allowed me to leave in the

<MvcBuildViews>true</MvcBuildViews>

option in my project file (which comes in handy with the T4MVC T4 template).

jimmay5469