I've been trying to deploy my ASP.NET MVC 3 Beta Application to my hosting. It supports all the necessary technologies and through trail and error I set the needed references' Copy Local
to True
. Then I got the error that my app cannot find the view. It listed .cshtml files it tried. I had those files in my project but they weren't deployed. I found that Visual Studio 2010 doesn't set .cshtml files' property Build Action
as Content
as it does for the .aspx files.
Is there a way to make Visual Studio automatically set .cshtml as Content, or will I have to set this manually to every Razor View I add?
While waiting for the final release which will have full Visual Studio integration and Intellisense with the Razor view engine you may checkout this blog post and especially the section: Changing The Default Build Action For a File-Type.
My team has been running into this problem as well. Even though we're all aware of the gotcha, it's too easy to forget to change the build action, and as a result you end-up w/ a runtime error.
I filed a bug on Connect to address this. Please up-vote and comment so this issue gets some traction.
http://connect.microsoft.com/VisualStudio/feedback/details/619539/mvc3-razor-views-and-partial-views-cshtml-are-not-marked-as-content
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With