简体   繁体   English

ASP.NET 核心 MVC - Model 属性传递给视图,显示 ZE405C1DF83BD248A07FC9A9122 中的 null

[英]ASP.NET Core MVC - Model properties passed to view showing null in Razor

I'm passing a view-model to a partial view and by stepping through the code I can tell that the expected data is there:我将视图模型传递给局部视图,并通过单步执行代码,我可以知道预期的数据在那里:

eg the BatteryLevelTooltip property例如BatteryLevelTooltip属性

正确数据

However, stepping over this, the BatteryLevelTooltip then becomes null and data isn't rendered in the view:但是,越过这个, BatteryLevelTooltip就会变成 null 并且数据不会在视图中呈现:

在此处输入图像描述

I cannot, for the life of me work out why.我不能,因为我一生都在弄清楚为什么。 I'm passing other data in the same way and that's being rendered fine further down the view.我以相同的方式传递其他数据,并且在视图的下方呈现得很好。

It turned out that for some reason I was setting this property in the getter of another property.事实证明,出于某种原因,我将此属性设置在另一个属性的 getter 中。 This was causing it to return null when it was accessed directly.这导致它在直接访问时返回 null。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 asp.net core 3 MVC上的模型绑定属性为空 - Model Binding properties null on asp.net core 3 MVC Asp.net MVC身份当前用户到剃刀视图的路径返回错误/将模型项传递到字典中 - Asp.net mvc identity current user path to razor view return error / The model item passed into the dictionary asp.net mvc模型属性为null - asp.net mvc model properties are null 成功登录并重定向到另一个剃须刀视图 ASP.NET Core MVC Web 应用程序后,UserIdentity 为 null - UserIdentity is null after successful login and redirection to another razor view, ASP.NET Core MVC web application IFormFile 始终为空(带有 MVC/Razor 的 ASP.NET Core) - IFormFile always null (ASP.NET Core with MVC/Razor) FullCalendar 未显示在 Asp.Net Core Razor 视图中 - FullCalendar not showing up in Asp.Net Core Razor View 在 ASP.Net Core 5 MVC 控制器中,当传递包含小数的 JSON 对象 FromBody 时,模型始终为空 - In ASP.Net Core 5 MVC Controller, when passed a JSON object FromBody that contains a decimal the model is always null 在 ASP.NET Core MVC Razor 视图中,与@model IEnumerable 相关的问题<namespace.model>对比@model<namespace.model></namespace.model></namespace.model> - In an ASP.NET Core MVC Razor view, issue related to @model IEnumerable<Namespace.Model> Vs @model<Namespace.Model> ASP.NET 核心 MVC 视图中的 Razor 页面路由问题 - Razor Pages routing issue in ASP.NET Core MVC view ASP.NET CORE,查看 model 的所有字段为 null 时传递回 Z9BBF373797BF7CF7BA62C80023 - ASP.NET CORE, View model has all fields as null when passed back to Controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM