Html.RenderPartial上的MVC System.Web.HttpCompileException [英] MVC System.Web.HttpCompileException on Html.RenderPartial

查看:72
本文介绍了Html.RenderPartial上的MVC System.Web.HttpCompileException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的视图调用Html.RederPartial时,我得到一个System.Web.HttpCompileException.异常消息是:

I'm getting an System.Web.HttpCompileException when the my view calls Html.RederPartial. The exception message is:

其他信息:外部组件引发了异常.

Additional information: External component has thrown an exception.

我检查了以下内容:

  • 控制器不会引发异常
  • 部分视图确实存在
  • 由控制器传递并由视图接收的Model是相同的.
  • InnerException为空
  • Controller doesn't throw an exception
  • Partial view does exist
  • The Model passed by controller and received by the view is the same.
  • The InnerException is null

异常听起来应该是html或razor格式错误或不正确,但是解决方案构建良好.不久前它还可以正常工作,所以我猜想,我缺少了一些愚蠢的东西...

The exception sounds like it should be that the html or razor is malformed or incorrect, but the solution builds fine. It was also working not too long ago, so I'm guessing, I'm missing something silly...

我的问题:

有人知道如何导致此异常吗?还是有办法获取有关该异常的更多信息?

Does anyone know how to know what causes this exception? Or is there a way to get more information on the exception?

编辑:这是StackTrace

Here's the StackTrace

在System.Web.Compilation.AssemblyBuilder.Compile() 在System.Web.Compilation.BuildProvidersCompiler.PerformBuild() 在System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) 在System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath,布尔值noBuild,布尔值...

at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean ...

推荐答案

原来,这对我来说是一个愚蠢的错误. MVC无法从Razor编译Html,因为我已经在我的Model中重命名了一个属性,但是没有在.cshtml中对其进行更新.

Turns out it was a silly mistake on my part. MVC couldn't compile the Html from Razor because I had renamed a property within my Model, but didn't update it in the .cshtml.

在编译时打开剃刀构建"错误.编辑您的csproj文件并设置以下内容:

Turn on Razor Build errors at compile time. Edit your csproj file and set the following:

<MvcBuildViews>true</MvcBuildViews>

感谢JP对此 SO帖子.

这篇关于Html.RenderPartial上的MVC System.Web.HttpCompileException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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