Reputation: 165
I have WebService and I'm using Postman to test it. But it keeps returning xml. I tried using [ScriptMethod(ResponseFormat = ResponseFormat.Json,UseHttpGet =false)]
in my WebMethod, also in postman the request is http://localhost:port/folder/service.asmx/HelloWorld
. In the config File I Have
<handlers>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" />
</handlers>
It still doesn't work and Postman returns xml
Upvotes: 0
Views: 1080
Reputation: 165
i'm posting the answer: I just uncommented:
[System.Web.Script.Services.ScriptService]
Upvotes: 1
Reputation:
You need to add reference from nuget packager for "Newtonsoft.Json" so you will be able to return data in JSON format.
return JsonConvert.SerializeObject(DataSet, Newtonsoft.Json.Formatting.Indented);
Upvotes: 0