The Case of the Missing config File

The Case of the Missing config File

While working on a code base that deploys to a CI environment, a “it work’s on my machine” moment occurred. In a brand new ASP.NET MVC 5 application that worked just fine locally, attempting to load any view resulted in a System.InvalidOperationException on the control environment. The exact exception was:

System.InvalidOperationException: The view at '~/Views/home/Index.cshtml' must derive from WebViewPage, or WebViewPage<TModel>.

In this particular CI environment, the deployment automation process has specific rules set up to exclude the copying of .config files. The reason for that exclusion isn’t all that important, but needless to say it’s a process that’s a work in progress. The root web.config contents are manually set on each deployment environment.

This was the first time this CI environment had an MVC deployed; it was previously set-up for ASP.NET web forms application. The root web.config was manually deployed, but it turns out the web.config in the Views folder that defines important config sections such as the one for the Razor view engine was forgotten. Once the Views web.config was deployed to the Views folder, this exception was resolved and the views began rendering.

Tags: Filled Under: Programming Posted on: April 17, 2014

Leave a Reply

Your email address will not be published. Required fields are marked *