部署到IIS上的asp.net网站后台的json反序列化
现在有一个要部署到IIS上的网站,在C#的后台json要进行反序列化,在本地上都是可以的,到了IIS上就提示:
System.InvalidOperationException: Cannot convert object of type 'System.String' to type 'System.Collections.Generic.List`1[Common.JsonRest]'
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)
at Common.JsonHelper.JSONStringToList[JsonRest](String strJson) in d:\MyBackup\我的文档\Visual Studio 2010\Projects\WebSite1 (4)\Common\JsonHelper.cs:line 41
at _Default.Page_Load(Object sender, EventArgs e)
求一个反序列化在IIS上可以的 求帮忙 这是现在用的方法 2个都不行。
public static T JsonDeserialize<T>(string jsonString)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
T obj = (T)ser.ReadObject(ms);
return obj;
}
public static List<JsonRest> JSONStringToList<JsonRest>(string strJson)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
List<JsonRest> objList = serializer.Deserialize<List<JsonRest>>(strJson);
return objList;
}