I’m experiencing some different behavior after switching from ASP.NET MVC 1.0 to ASP.NET MVC 2 Beta. I checked the breaking changes but it’s not clear where the issue lies.
The problem has to do with the default model binder and a model that implements IDataErrorInfo.
The property (IDataErrorInfo.Item):
public string this[string columnName]
is no longer being called for each property. What am I missing?
After some further debugging work I believe I understand why in my particular case the
IDataErrorInfo.Itemisn’t being called. The following code is used in the ASP.NET MVC 2 Beta to validate anIDataErrorInfoproperty:My model contains a property that is
System.Nullable<int>and when the model binder binds an empty string from the HTML post, theMetadata.Modelis equal to null, thus the validation doesn’t run.This is fundamentally different from ASP.NET MVC 1.0, where this scenario fires the validator all the way through to a call to
IDataErrorInfo.Item.Am I just not using something the way it was intended?