Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
<!DOCTYPE html>
↵<html>
↵    <head>
↵        <title>An item with the same key has already been added.</title>
↵        <meta name="viewport" content="width=device-width" />
↵        <style>
↵         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
↵         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
↵         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
↵         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
↵         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
↵         pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
↵         .marker {font-weight: bold; color: black;text-decoration: none;}
↵         .version {color: gray;}
↵         .error {margin-bottom: 10px;}
↵         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; }
↵         @media screen and (max-width: 639px) {
↵          pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
↵         }
↵         @media screen and (max-width: 479px) {
↵          pre { width: 280px; }
↵         }
↵        </style></head>
↵
↵    <body bgcolor="white">
↵
↵            <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
↵
↵            <h2> An item with the same key has already been added. </h2></span>
↵
↵            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
↵
↵             Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
↵
↵            <br><br>
↵
↵             Exception Details: System.ArgumentException: An item with the same key has already been added.<br><br>
↵
↵            Source Error: <br><br>
↵
↵            <table width=100% bgcolor="#ffffcc">
↵               <tr>
↵                  <td>
↵                      <code>
↵
↵An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.                      </code>
↵
↵                  </td></tr></table>
↵
↵            <br>
↵
↵            Stack Trace: <br><br>
↵
↵            <table width=100% bgcolor="#ffffcc">
↵               <tr>
↵                  <td>
↵                      <code><pre>
↵
↵[ArgumentException: An item with the same key has already been added.]
↵   System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +56
↵   System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +12946796
↵   System.Collections.Generic.CollectionExtensions.ToDictionaryFast(TValue[] array, Func`2 keySelector, IEqualityComparer`1 comparer) +116
↵   System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +149
↵   System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +176
↵   System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +101
↵   System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +55
↵   System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1209
↵   System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +333
↵   System.Web.Mvc.DefaultModelBinder.GetPropertyValue(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, IModelBinder propertyBinder) +17
↵   System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +377
↵   System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +101
↵   System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +55
↵   System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1209
↵   System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +333
↵   System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +336
↵   System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +105
↵   System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__0(AsyncCallback asyncCallback, Object asyncState) +640
↵   System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +14
↵   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
↵   System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +346
↵   System.Web.Mvc.<>c.<BeginExecuteCore>b__152_0(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +27
↵   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
↵   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
↵   System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +494
↵   System.Web.Mvc.<>c.<BeginExecute>b__151_1(AsyncCallback asyncCallback, Object callbackState, Controller controller) +16
↵   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
↵   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
↵   System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +403
↵   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
↵   System.Web.Mvc.<>c.<BeginProcessRequest>b__20_0(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +54
↵   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
↵   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
↵   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +427
↵   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
↵   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
↵   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +444
↵   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +132
↵   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163
↵


↵ ↵ ↵







Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4001.0








I had tried to cal ajax post method like
JavaScript


$.ajax({
url:'/Cart/cartmodel',
type:'POST',
data:json.stringfy(data),
ContentType:'application/json;charset=utf-8',
Success:function(result){

}
error:function(JqXHR,Status,thrownerror){
var response=jquery.ParseJson(JqXHR.reponsetext)
}


});


I don't have duplication properties on modal

What I have tried:

An item with the same key has already been added
Posted
Updated 29-Jan-21 4:01am

1 solution

It's impossible to guess, without seeing code-behind. But below thread has 20+ answers for this error message. So check those & make changes in your code.

asp.net mvc - An item with the same key has already been added - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900