ASP.Net MVC - 在查看编译器错误 [英] ASP.Net MVC - Compiler Errors in Views

查看:128
本文介绍了ASP.Net MVC - 在查看编译器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有人能解释为什么Visual Studio中不报告上查看页面编译错误?

I wonder if anyone can explain why Visual Studio does not report compile errors on the View Pages?

我问,因为我注意到,重新沙坡(至少我认为这是)拿起我已包括在我看来,一个死全球化志愿服务青年,但项目将建设的事实。

I ask because I noticed that Re-Sharper (At least i think it is) picks up the fact that I have included a dead referance in my view but the project will build.

例如,

<%@ Import Namespace="Site.This.Is.Dead.Link"%>

只是导航到该显示此错误的页面时,它的。我想用MVC,因为在查看一些逻辑和referances,这将是编译器报告错误是好事。但是我想知道是否有一个坚实的理由,这不是这种情况?

Its only when navigating to the page that this error is displayed. I think with MVC, as there is some logic and referances in the View, it would be a good thing for the compiler to report the error. However i'd like to know if there is a solid reason that this not be the case?

推荐答案

为了让你发现在编译时这些错误,ASP.NET MVC项目现在包括MvcBuildViews属性,它默认是禁用的。要启用此属性,打开该项目文件和MvcBuildViews属性设置为真正,如下图所示下面的示例/图所示:

To let you detect these errors at compile time, ASP.NET MVC projects now include an MvcBuildViews property, which is disabled by default. To enable this property, open the project file and set the MvcBuildViews property to true, as shown in the following example/image below:

    <MvcBuildViews>true</MvcBuildViews>

这篇关于ASP.Net MVC - 在查看编译器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆