C# 邮递员无法从asmx服务返回json

C# 邮递员无法从asmx服务返回json,c#,web,service,C#,Web,Service,我有WebService,我正在用Postman来测试它。但它不断返回xml。我尝试在我的WebMethod中使用[ScriptMethodResponseFormat=ResponseFormat.Json,UseHttpGet=false],在postman中也是如此http://localhost:port/folder/service.asmx/HelloWorld. 在配置文件中,我有 <handlers> <add name="ScriptHandlerFa

我有WebService,我正在用Postman来测试它。但它不断返回xml。我尝试在我的WebMethod中使用[ScriptMethodResponseFormat=ResponseFormat.Json,UseHttpGet=false],在postman中也是如此http://localhost:port/folder/service.asmx/HelloWorld. 在配置文件中,我有

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

它仍然不起作用,Postman返回xml

您需要添加nuget packager for Newtonsoft.Json的引用,以便能够以Json格式返回数据

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

我在发布答案:我只是没有注释:

[System.Web.Script.Services.ScriptService]