api 请求返回 json 文件而不是 html/xml 浏览器内容
我正在向 facebook graph api 发送 get httpwebrequests ,一切都工作正常,直到我部署到生产服务器,现在期望 html/xml 响应的模块不起作用,当在 Internet Explorer 中测试 url 时,会弹出保存文件对话框并生成文件需要保存。 其他模块也向 facebook 图发送请求,但只是请求形式不同,所以不确定这里发生了什么。
任何想法表示赞赏
编辑:
让我尝试重新表述这一点。在我的生产服务器上,httpwebrequest 没有返回正确的结果。因此,为了测试它,我复制了网址 http://graph.facebook.com/pepsi 这是一个示例,应返回可在浏览器中查看的个人资料信息。服务器有 Internet Explorer v8,我不确定为什么它尝试下载文件而不是在浏览器中显示它。这就是我的代码中发生的情况,当我向 api 的不同部分发出请求时,它可以在我的应用程序中运行,但不能在浏览器中运行
I am sending get httpwebrequests to the facebook graph api and all was working fine till I deployed to production server and now module that expects html/xml response is not working and when tested url in internet explorer, the save file dialog pops up and the file needs to be saved.
Other modules also send requests to the facebook graph but just differ in the form of requests so not sure what is going on here.
Any ideas appreciated
Edit:
Let me try and rephrase this. On my production server the httpwebrequest was not returning the correct result. So to Test it I copied the url http://graph.facebook.com/pepsi which is an example, should return the profile info viewable in the browser. The server has internet explorer v8 and I am not sure why it tries to download the file instead of displaying it in the browser. this is what is happening in my code and when I make a request to a different part of the api, then it works in my app but not in the browser
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题不是很清楚。据我收集的信息,您希望在浏览器中显示 JSON 响应。相反,浏览器会要求您下载文件。
嗯,这是正常行为。您从 Facebook 获得的响应很可能具有 MIME 类型
应用程序/json
。大多数较新的网络浏览器在浏览器本身中显示文本。然而,有些浏览器不知道如何处理这种内容类型,只是要求您下载该文件。您提到您的模块需要 html/xml 响应。尝试将其更改为 application/json。
您还说它可以在您的应用程序中运行,但不能在浏览器中运行。我不知道你在做什么,但通常你不会在浏览器中向用户显示原始 json,对吧?
Your question is not very clear. From what I gather, you want the display the JSON response in a browser. Instead, you are being asked to download a file by the browser.
Well, this is normal behaviour. The response you get from Facebook would most likely have a MIME type of
application/json
. Most newer web browsers display the text in the browser itself. Some browsers, however don't know how to handle this content type and just ask you to download the file.You mentioned that your module expects an html/xml response. Try changing this to application/json.
You also said that it works in your app but not in your browser. I don't know what you're making, but generally you wouldn't show raw json to the user in a browser, right?