C# TryUpdateModel不使用字典<;枚举、字符串>;

C# TryUpdateModel不使用字典<;枚举、字符串>;,c#,asp.net-mvc,enums,formcollection,model-binders,C#,Asp.net Mvc,Enums,Formcollection,Model Binders,假设这些类\枚举: public enum Test { MyTest1 = 0, MyTest2, MyTest3, } public class Model { public Dictionary<Test, string> TestDictionary { get; set; } public Dictionary<string, string> StringDictionary { get; set; } publ

假设这些类\枚举:

public enum Test
{
    MyTest1 = 0,
    MyTest2,
    MyTest3,
}

public class Model
{
    public Dictionary<Test, string> TestDictionary { get; set; }
    public Dictionary<string, string> StringDictionary { get; set; }
    public string Other { get; set; }

    public Model()
    {
        TestDictionary = new Dictionary<Test, string>();
        StringDictionary = new Dictionary<string, string>();
    }
}
Model.StringDictionary
get已成功更新。
我无法获取更新的
模型.TestDictionary

我尝试了很多方法,比如将输入名称更改为
Test.MyTest1
,但都无法实现


我的输入应该是什么样子的id我想填充
模型。TestDictionary

我发现了一个很难解决的问题:

<input type="hidden" name="Model.TestDictionary[0].Key" value="MyTest1" />
<input type="hidden" name="Model.TestDictionary[0].Value" value="myval" />


不管怎样,如果有人发现更好的东西,那就很高兴看到。

检查这个主题@Kamo-谢谢你的回答。这不是这里的问题,因为活页夹查找“第一级”属性(在我的例子中是两个字典和一个字符串)。
public ActionResult Test(FormCollection formCollection)
{
    Model model = new Model();
    TryUpdateModel(model, "Model");
    return Redirect("Index");
}
<input type="hidden" name="Model.TestDictionary[0].Key" value="MyTest1" />
<input type="hidden" name="Model.TestDictionary[0].Value" value="myval" />