当请求为 POST 时如何从 IIS7 提供 .json 文件
我有一个 asp.net 4.0 网站,需要提供 .json 类型的文件。该请求以 POST 形式传入,但不起作用。 GET 工作正常。有人知道我需要更改什么配置才能使其工作吗?
I have an asp.net 4.0 web site that needs to serve files of type .json. The request is coming in as a POST, which does not work. GET works fine. Anyone know what configuration I need to change to make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能已经找到了答案,但我认为问题在于您需要为您的 Web 服务器添加一个“.json”处理程序...
默认情况下,IIS 未配置为处理 .json 扩展名。
您可以将 mime 类型应用为 IIS 根目录上的处理程序,这样 .json 就可以由 IIS 中的每个站点或虚拟文件夹处理,或者仅处理到特定站点。
(或 Apache,如果您在开发端。 ..)
阿帕奇模块mod_mime AddType
注意:在 Ubuntu 中,您还需要编辑文件 /etc/mime.types 并添加以下行:
然后重新启动 Apache
You probably already found the answer, but I think the problem lies in that you need to add a ".json" handler for your web server...
By default IIS is not configured to handle .json extension.
You can apply the mime type as a handler on the root of IIS so .json can be handled by every site or virtual folder in the IIS or just to the specific site.
(or Apache, if you're on the dev side...)
Apache Module mod_mime AddType
Note: In Ubuntu you ALSO need to edit the file /etc/mime.types and add the line:
Then restart Apache
GET 或 POST 无关紧要,它与程序发送的响应类型无关。
没有任何设置会产生影响。你的问题是程序中的逻辑错误。
GET or POST is irrelevant, its got nothing to do with the type of response your program sends.
There is no setting that would make a difference. Your problem is a logic error in your program.