我收到以下 InvalidOperationException:
The parameter conversion from type 'System.String' to type 'System.Runtime.Serialization.ExtensionDataObject' failed because no type converter can convert between these types.
在我的 ASP.Net MVC2 页面上的 Post 操作中,但我真的不确定它指的是什么。我正在使用数据注释验证:
public class FamilyPersonMetadata
{
[Required(ErrorMessage = "Name Required")]
public String Name;
[Required(ErrorMessage = "Date of Birth required")]
[DateTime(ErrorMessage = "Invalid Date")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d")]
public DateTime DateOfBirth;
}
[MetadataType(typeof(FamilyPersonMetadata))]
public partial class FamilyPerson
{
}
我的视图继承自具有 FamilyPerson 子类型的 ViewPage。我只是创建名称与 FamilyPerson 匹配的控件,然后提交表单,但由于某种原因,我的 ModelState 无效,上述错误显然是原因。我对错误的性质感到非常困惑。类似的代码适用于其他视图和操作。
有人可以指出我可能会导致这种情况的事情的方向吗?