Visual Studio 2010 / ASP.NET MVC / Publish

Posted by SevenCentral on Stack Overflow See other posts from Stack Overflow or by SevenCentral
Published on 2010-04-14T23:30:40Z Indexed on 2010/04/14 23:33 UTC
Read the original article Hit count: 331

I just did a clean install on Windows 7 x64 Professional with the final release of Visual Studio 2010 Premium. In order to duplicate what I'm experiencing do the following in:

  1. Create a new ASP.NET MVC 2 Web Application
  2. Right click the project and select Properties
  3. On the Web tab, select "Use Local IIS Web Server"
  4. Click on Create Virtual Directory
  5. Save all
  6. Unload the project
  7. Edit the project file
  8. Change MvcBuildViews to true
  9. Save all
  10. Reload project
  11. Right click the project and select Publish
  12. Choose the file system publish method
  13. Enter a target location
  14. Choose Delete all existing files
  15. Select Publish
  16. Right click the project
  17. Select Publish

Each time I do the above I get the following errror:

"It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level..."

The error originates from obj\debug\package\packagetmp\web.config, relative to the project directory. I can repeat this all day long with any MVC 2 project I've built.

In order to fix this problem, I need to set MvcBuildViews to false in the project file. That's not really an option.

This wasn't a problem in Visual Studio 2008 and it seems to be an issue with the way the Publish command stages files beneath the project directory.

Can anyone else duplicate this error? Is this a bug or by design? Is there a fix, workaround, etc...?

Thanks.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc