【发布时间】:2010-10-28 01:07:11
【问题描述】:
我正在将脚本从 PHP 转换为 ASP.net C#。在 PHP 中,我可以使用类似的东西:
header('Content-type: text/json');
header('Content-type: application/json');
如何告诉我的 aspx 页面在标题中声明它正在打印 JSON 文件?
【问题讨论】:
标签: c# php asp.net json header
我正在将脚本从 PHP 转换为 ASP.net C#。在 PHP 中,我可以使用类似的东西:
header('Content-type: text/json');
header('Content-type: application/json');
如何告诉我的 aspx 页面在标题中声明它正在打印 JSON 文件?
【问题讨论】:
标签: c# php asp.net json header
Response.ContentType = "application/json";
或更一般地
Response.Headers.Add("Content-type", "text/json");
Response.Headers.Add("Content-type", "application/json");
【讨论】:
有关 JerSchneid 答案的其他信息
如果您收到这样的错误消息:
此操作需要 IIS 集成管道模式。
你可以这样使用:
Response.AddHeader("Content-type", "text/json");
【讨论】: