Friday, June 28, 2013

MVC application deployed with Visual Studio setup project does not behave like an MVC application

This post is for you if your MVC web application works when debugged and works when published using the built-in Visual Studio publish mechanism, but fails when deployed using a Visual Studio web setup project.  You may receive errors in the browser that indicate directory browsing is not enabled/permitted.

The reason is likely because you added 'primary output' from your web application project to the setup project, but failed to include 'content files'.  Content files include the web.config file, which the web application needs for proper operation.  Right click on the setup project node and click Add | Project Output.  Select the web application project from the drop down and select 'Content Files' and then OK.