且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Razor 视图引擎和 ASP.NET MVC 3 中使用动态模型渲染局部视图

更新时间:2022-12-20 15:35:21

刚刚找到答案,看来我放置RenderPartial代码的视图有一个动态模型,因此MVC无法选择正确的方法使用.将 RenderPartial 调用中的模型转换为正确的类型解决了该问题.

Just found the answer, it appears that the view where I was placing the RenderPartial code had a dynamic model, and thus, MVC couldn't choose the correct method to use. Casting the model in the RenderPartial call to the correct type fixed the issue.

来源:在 ascx 文件中使用 Html.RenderPartial()