Postman无法从asmx服务返回json

问题描述:

我有WebService,我正在使用Postman进行测试。但它不断返回XML。我试过在我的WebMethod中使用[ScriptMethod(ResponseFormat = ResponseFormat.Json,UseHttpGet =false)],同样在邮递员的请求是http://localhost:port/folder/service.asmx/HelloWorld。在配置文件中我有Postman无法从asmx服务返回json

<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> 

它仍然无法正常工作和邮差返回XML

你需要从的NuGet打包添加引用为“Newtonsoft.Json”这样你就可以返回数据JSON格式。

return JsonConvert.SerializeObject(DataSet, Newtonsoft.Json.Formatting.Indented); 

我张贴的答案:我只是取消注释:

[System.Web.Script.Services.ScriptService]