gpt4 book ai didi

c# - Html.RenderPartial 上的 MVC System.Web.HttpCompileException

转载 作者:太空狗 更新时间:2023-10-29 18:08:12 25 4
gpt4 key购买 nike

当我的 View 调用 Html.RederPartial 时,我得到一个 System.Web.HttpCompileException。异常信息是:

Additional information: External component has thrown an exception.

我已经检查过:

  • Controller 没有抛出异常
  • 局部 View 确实存在
  • Controller 传递的模型和 View 接收的是一样的。
  • InnerException 为空

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

我的问题:

有谁知道如何知道导致此异常的原因?或者有没有办法获得有关异常的更多信息?

编辑:这是 StackTrace

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

在编译时打开 Razor Build 错误。编辑您的 csproj 文件并设置以下内容:

<MvcBuildViews>true</MvcBuildViews>

感谢 JP 提供此 SO post .

关于c# - Html.RenderPartial 上的 MVC System.Web.HttpCompileException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31608851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com