ASP.Net MVC - 视图中的编译器错误 [英] ASP.Net MVC - Compiler Errors in Views

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

问题描述

我想知道是否有人可以解释为什么 Visual Studio 没有在查看页面上报告编译错误?

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

我之所以这么问是因为我注意到 Re-Sharper(至少我认为是这样)发现我在我的视图中包含了一个无效的引用但该项目将构建的事实.

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,由于View中有一些逻辑和引用,编译器报告错误会是一件好事.但是我想知道是否有充分的理由表明情况并非如此?

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 属性设置为 true,如下面的示例/图像所示:

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天全站免登陆