Asp.net mvc 提交时引发异常:已添加具有相同键的项
我的控制器没有在提交时从查看页面调用,而是在我点击提交按钮时收到一条错误消息 错误:已添加具有相同密钥的项。 堆栈跟踪:Asp.net mvc 提交时引发异常:已添加具有相同键的项,asp.net-mvc,Asp.net Mvc,我的控制器没有在提交时从查看页面调用,而是在我点击提交按钮时收到一条错误消息 错误:已添加具有相同密钥的项。 堆栈跟踪: [ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52 System.Collections.Generic.Dictionary`
[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +9382923
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +252
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer) +91
System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +228
System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +392
System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +147
System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +98
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +2504
System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +548
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +473
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +181
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +830
System.Web.Mvc.Controller.ExecuteCore() +136
可能需要更多的代码来回答您的问题,比如Aciton方法和表单
我猜模型绑定正在尝试添加两个具有相同名称/ID的表单值,但失败了,因此我会检查您的视图代码以确保您没有两次使用相同的ID标记 可能需要更多的代码来回答您的问题,比如Aciton方法和表单
我猜模型绑定正在尝试添加两个具有相同名称/ID的表单值,但失败了,因此我会检查您的视图代码以确保您没有两次使用相同的ID标记 视图模型可能有两个同名属性,例如UserName和UserName。当MVC进行模型绑定时,由于它不区分大小写,它会认为您有两个相同的属性。您的视图模型可能有两个同名属性,例如UserName和UserName。当MVC进行模型绑定时,由于它不区分大小写,它会认为您有两个相同的属性。猜测-表单中有两个元素具有相同的id。猜测-表单中有两个元素具有相同的id。7年后;7年后有帮助;这很有帮助。