在 ASP.NET 上创建 JSON 标头
我正在将脚本从 PHP 转换为 ASP.net C#.在 PHP 中,我可以使用类似的东西:
I am converting a script from PHP to ASP.net C#. In PHP, i could use something like:
header('Content-type: text/json');
header('Content-type: text/json');
header('Content-type: application/json');
header('Content-type: application/json');
如何告诉我的 aspx 页面在标题中声明它正在打印 JSON 文件?
How can I tell my aspx page to declare in the header that it is printing a JSON file?
推荐答案
Response.ContentType = "application/json";
或更一般地
Response.Headers.Add("Content-type", "text/json");
Response.Headers.Add("Content-type", "application/json");
相关文章