具有继承性的模型的 asp.net mvc 默认模型绑定器
我有一个绑定到的表单,其结构如下:
public class Status
{
public List<ABCAttachment> ABCAttachments_Files { get; set; }
}
public class Attachment
{
public string Id { get; set; }
}
public class ABCAttachment : Attachment
{
string Name { get; set; }
}
我的操作如下所示:
public ActionResult SaveAttachment(Status status)
{
....
}
数据以表单形式传输
ABCAttachments_Files[0].Id="0", ABCAttachments_Files[0].Name="test"
当我在 SaveAttachments 操作中访问状态时,ID 存在,但名称不存在。我看到它已正确发布,但为什么它没有正确绑定?
I have a form that I binding to that has the following structure:
public class Status
{
public List<ABCAttachment> ABCAttachments_Files { get; set; }
}
public class Attachment
{
public string Id { get; set; }
}
public class ABCAttachment : Attachment
{
string Name { get; set; }
}
My action looks like this:
public ActionResult SaveAttachment(Status status)
{
....
}
The data is coming over in the form
ABCAttachments_Files[0].Id="0", ABCAttachments_Files[0].Name="test"
When I access status in my SaveAttachments action the Id is there, but the Name is not. I see it correctly being posted, but why is it not binding properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来
Name
属性需要是公共的,否则它不会被限制为:应该是
Looks like the
Name
property needs to be public or it won't be bounded to:should be