Visual Studio 2010 doesn't set .CSHTML (Razor View Engine) as Content
I've been trying to deploy my ASP.NET MVC 3 Beta Application to my hosting. It supports all the necessary technologies and开发者_如何学JAVA 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
精彩评论