【发布时间】:2013-02-22 11:35:50
【问题描述】:
我有这个错误
无法将类型 \u0027System.String\u0027 的对象转换为类型 \u0027System.Collections.Generic.Dictionary2[System.String,System.Int32]\u0027","StackTrace":" at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary2 rawParams)\r\n 在 System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(对象目标,IDictionary@987654322 @2 rawParams)\r\n 在 System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException
当我使用 Dictionary 将数组传递给 WebMethod 时
【问题讨论】:
-
您是否尝试在 webmehtod/webapi 项目的参数中传递 Dictionary
对象?? -
不,我让 forloop 在 forloop 中创建新对象以将其推送到数组中并生成 JSON.stringify(array) 但得到相同的错误
标签: javascript jquery asp.net json json.net