Visual Studio 2010 未将 .CSHTML(Razor 视图引擎)设置为内容
我一直在尝试将 ASP.NET MVC 3 Beta 应用程序部署到我的托管。它支持所有必要的技术,通过反复试验,我将所需引用的 Copy Local
设置为 True
。然后我收到错误,我的应用程序找不到视图。它列出了它尝试过的 .cshtml 文件。我的项目中有这些文件,但它们没有部署。我发现 Visual Studio 2010 没有像 .aspx 文件那样将 .cshtml 文件的属性 Build Action
设置为 Content
。
有没有办法让 Visual Studio 自动将 .cshtml 设置为内容,或者我必须手动将其设置到我添加的每个 Razor 视图?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在等待最终版本时,它将具有完整的 Visual Studio 集成和 Intellisense 与 Razor 视图引擎,您可以查看 这篇博文,特别是以下部分:更改文件类型的默认构建操作< /em>。
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.
我的团队也遇到了这个问题。尽管我们都知道陷阱,但很容易忘记更改构建操作,最终导致运行时错误。
我在 Connect 上提交了一个错误来解决这个问题。请投票并发表评论,以便这个问题得到一些关注。
http://connect.microsoft.com/VisualStudio/feedback/details/619539/mvc3-razor-views-and-partial-views-cshtml-are-not-marked-as-content
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