public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var key = new Dictionary<string, object>();
key.Add("CPLID", new object());
key.Add("EqID", new object());
key.Add("Shift", new object());
key.Add("DateTime", new object());
key.Add("UpdateDateTime", new object());
key.Add("No", new object());
key.Add("LineStop.Remark", new object());
key.Add("IsRemark", new object());
key.Add("DispatchID", new object());
key.Add("CopperID", new object());
key.Add("CopperLV", new object());
key.Add("InThickness", new object());
key.Add("InWidth", new object());
key.Add("OutWidth", new object());
key.Add("OutLength", new object());
key.Add("OutPiece", new object());
key.Add("WeldingNum", new object());
key.Add("GuideNum", new object());
key.Add("Supply", new object());
key.Add("Produce", new object());
key.Add("ReturnMaterial", new object());
key.Add("StartTime", new object());
key.Add("EndTime", new object());
key.Add("PrelineNum", new object());
key.Add("SelflineNum", new object());
key.Add("ProcessModeNum", new object());
key.Add("ProcessResultNum", new object());
key.Add("ProcessMode[0].CopperID", new object());
key.Add("ProcessMode[0].Mode", new object());
key.Add("ProcessMode[1].CopperID", new object());
key.Add("ProcessMode[1].Mode", new object());
key.Add("ProcessMode[2].CopperID", new object());
key.Add("ProcessMode[2].Mode", new object());
key.Add("ProcessMode[3].CopperID", new object());
key.Add("ProcessMode[3].Mode", new object());
//key.Add("ProcessMode[4].CopperID", new object());
//key.Add("ProcessMode[4].Mode", new object());
DictionaryValueProvider<object> ob = new DictionaryValueProvider<object>(key, CultureInfo.CurrentCulture);
Assert.IsTrue(ob.ContainsPrefix("ProcessMode"));
}
}
Above sample test code running in MVC3 is work.
howerver, “ContainsPrefix” method is fine at MVC3,but It’s don’t work correct at MVC4.
And then, when I try to add more item. Something like
ProcessMode[4].CopperID and ProcessMode[4].Mode (remove comment)..
It work correct at MVC4.
I think it is very strange,
The problem sometimes make an error: “Post a ajax with json content” and DefaultModelBinder that it produce an data which it is faule.
Is the method ContainsPrefix is different in MVC3 and MVC4?
12/7 update
http://forums.asp.net/t/1856357.aspx/1?FormValueProvider+skips+form+values
the same question, it let me cant use MVC4
search for prefixes string with ‘binary search’
make the ‘.’ and ‘[‘ skips match
I found the solution……………………….:
http://weblogs.asp.net/imranbaloch/archive/2012/12/08/fixing-model-the-binding-issue-of-asp-net-mvc-and-asp-net-web-api.aspx