Web方法无法删除对象{d:""}我想做的是不发送对象{d:"{"FileID":"1213"}"}send"{"FileID":"1213"}"我当前的代码:usingSystem;使用System.Web.Mvc;使用系统数据;使用System.Data.SqlClient;使用系统配置;使用系统。网络;使用System.Web.Services;使用System.Web.Script.Services;使用System.Web.Script.Serialization;[ScriptService]partialclasstesting_class:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){Session["FileID"]=Request.QueryString["FileID"];}publicstaticstringreturnJSON(objecto){JavaScriptSerializerjs=newJavaScriptSerializer();返回js.Serialize(o);}[WebMethod][ScriptMethod(UseHttpGet=true,ResponseFormat=ResponseFormat.Json)]publicstaticstringCurrentFile(){vard=new{FileID="123"};返回returnJSON(d);}};MicrosoftStackJson序列化程序已过时,应不惜一切代价避免使用它。相反,您应该使用(默认情况下已经是新的.NETWeb堆栈)Json.NET实现。如果您没有安装它,可以通过在NuGet控制台窗口中运行Install-PackageNewtonsoft.Json来安装。还要确保您使用的是Newtonsoft.Json;.以上是C#学习教程:Web方法无法删除对象{d:""}共享的所有内容。如果对大家有用,需要进一步了解C#学习教程,希望大家多加关注——d=new{文件ID="123"};返回JsonConvert.SerializeObject(d);}本文收集自网络,不代表立场,如有侵权请点右联系管理员删除。如需转载请注明出处:
