我有一个具有显式属性的模型类,它似乎MVC活页夹不绑定它们。我得到错误MVC绑定显式属性
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary
这是已知的问题吗?我无法在google上找到关于此的任何文档。
我班
public interface IPdf2Source
{
string Password { get; set; }
string OutputFormatSelected { get; set; }
}
public class OptionModel : IPdf2Source
{
public IPdf2Source Pdf2Source
{
get { return this; }
}
//Bind Ok
public string Email { get; set; }
//I get error on these properties while binding.
string IPdf2Source.Password { get; set; }
string IPdf2Source.OutputFormatSelected { get; set; }
}
查看
@using (Html.BeginForm())
{
@Html.TextBoxFor(p => p.Email)
@Html.TextBoxFor(p => p.Pdf2Source.Password)
@Html.HiddenFor(p=>p.Pdf2Source.OutputFormatSelected)
}
控制器动作,因为绑定失败这是永远不会被调用。如果我删除显式声明的属性,一切工作正常。
public JsonResult ValidateFile(OptionModel formData)
{
}
显示一些代码。 – 2012-03-23 07:59:25
我已更新帖子。 – Tomas 2012-03-23 08:01:46
请在您的问题中显示一些代码,以便我们可以更好地了解您的问题。添加尽可能多的代码。 – 2012-03-23 08:02:30