使用webApi在浏览器中生成JSON结果 [英] JSON results in browser using webApi
问题描述
大家好,
我使用VS 2017创建了一个WebApi,其中正在连接到多个数据库并获取结果,
I have created an WebApi using VS 2017 , where am connecting to multiple database and getting the results,
当我返回结果时,输出以save/saveAs的JSON文件形式出现,
when I return the result, the output comes in JSON file for save/saveAs ,
当我们获得XML结果时,我应该怎么做才能在浏览器中获取JSON详细信息.
what should I do to get the JSON details in Browser, as we get our XML results.
非常感谢
推荐答案
您是通过AJAX调用Web API还是只是使用浏览器?
Did you call the Web API via AJAX or just use your browser ?
对于IE浏览器,当响应数据为JSON时,它将执行下载操作(保存/另存为),但对于Chrome,它将显示在浏览器中.
For IE browser, it will do download operation(save/save as) when the response data is JSON, but for Chrome, it will be shown in browser.
为了测试您的Web API,我建议使用"PostMan",它是一个很好的开发工具: https://www.getpostman .com/
For test your Web API, I recommend to use "PostMan", it is a good development tool:https://www.getpostman.com/
最诚挚的问候,
李刘
这篇关于使用webApi在浏览器中生成JSON结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!