[ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetData() { var List = Data.ToList(); return new JavaScriptSerializer().Serialize(List); } And my code in Client is $.ajax({ type: 'Post', url: "http://localhost/service/WebService.asmx?op=Method", contentType: "application/json", dataType: "json", success: function (data) { console.log(data); }, error: function (error, status) { console.log("status = " + status); console.log(error); } }); But I am getting an error "<soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:body><soap:fault><soap:code><soap:value>soap:Receiver</soap:value></soap:code><soap:reason><soap:text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read() at System.Xml.XmlReader.MoveToContent() at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent() at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement() at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) --- End of inner exception stack trace ---</soap:text></soap:reason><soap:detail /></soap:fault></soap:body></soap:envelope>" Why this happens
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)