views:

97

answers:

1

I am in the early stages of developing an Azure web project which will likely take more than six months to complete. The views which make up the UI would benefit from clean syntax provided by the Razor view engine found in the MVC 3 preview 1.

The following exception is thrown whenever the site is run as an Azure web role:

InvalidOperationException: The view 'Index' or its master was not found.
The following locations were searched:  
  ~/Views/Content/Index.aspx  
  ~/Views/Content/Index.ascx  
  ~/Views/Shared/Index.aspx  
  ~/Views/Shared/Index.ascx  
  ~/Views/Content/Index.cshtml  
  ~/Views/Shared/Index.cshtml  

Notes:

  • The site runs as expected when started as a standalone instance (which seems to validate that the upgrade from MVC 2 to 3 worked correctly -- see next two points)
  • The '~/Views/Content/Index.cshtml' file exists as well as the '~/Views/Shared/_Layout.cshtml' LayoutPage it references.
  • I followed the steps from the MVC 3 Preview 1 Release Notes (replaced reference to 2.0 version of System.Web.Mvc with 3.0, modified the ProjectTypeGuids in the csproj file, and updated bindingRedirect versions).
  • Searching Google resulted in one suggestion to set Copy Local to 'True' for the System.Web.Mvc.dll. It appears that the page was referencing an older version of MVC. Making that change didn't help.

Edit:

  • I just got the idea to dig around the Azure directories a little more. It appears the build process that the Azure Cloud Service uses skips over .cshtml files. Manually copying the files to the Azure role directories causes the page to load as expected. If I can't figure out what copies these files I will probably just create a post build script.
+1  A: 

When right clicking in a ActionResult method and selecting 'Add View', the CSHTML view file is created in a view directory however the Build Action property of the file is set to 'None' rather than 'Content'.

Robert