在创建ASP.NET一个JSON头 [英] Creating a JSON Header on ASP.NET

查看:243
本文介绍了在创建ASP.NET一个JSON头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把从PHP脚本ASP.net C#。在PHP中,我可以使用类似:

标题(内容类型:文本/ JSON');

标题(内容类型:应用程序/ JSON');

如何知道我的aspx页面,它正在打印JSON文件头要申报吗?


解决方案

  Response.ContentType =应用/ JSON;

或更一般

  Response.Headers.Add(内容类型,文/ JSON);
Response.Headers.Add(内容类型,应用/ JSON);

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: application/json');

How can I tell my aspx page to declare in the header that it is printing a JSON file?

解决方案

Response.ContentType = "application/json";

or more generally

Response.Headers.Add("Content-type", "text/json");
Response.Headers.Add("Content-type", "application/json");

这篇关于在创建ASP.NET一个JSON头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆