【小5聊】C#基础之Response.ContentType响应内容类型

【开发环境】
开发系统:Windows 10
开发平台:.Net Framework 4.6.1(系统框架)
开发语言:C#
文章作用:记录、备忘、总结、分享、理解

 

1、实际应用测试,代码如下

#region 测试
public void Test()
{
    //Response.ContentType = "application/json";
    Response.Write("{\"code\":\"200\",\"message\":\"测试信息\"}");
}
#endregion

2、使用Postman工具调用接口,效果如下

3、设置响应内容类型改为json类型,效果如下

 

 

Response.ContentType

1、文本格式:html、xml、txt

Response.ContentType = "text/html ";

Response.ContentType = "text/xml";

Response.ContentType = "text/plain";

2、图片格式

Response.ContentType = "image/jpg";

Response.ContentType = "image/png";

Response.ContentType = "image/gif";

3、媒体格式

Response.ContentType = "application/json"; //比较常用

Response.ContentType = "application/xml";

Response.ContentType = "application/xhtml+xml";

Response.ContentType = "application/atom+xml";

Response.ContentType = "application/pdf";

Response.ContentType = "application/msword";

Response.ContentType = "application/octet-steam";

Response.ContentType = "application/x-www-form-urlencoded";

 

【一句话一感想一心情】版本更新,增加测颜值推荐图文,来体验下句子的魅力

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

全栈小5

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值