加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 添加context.Response.Headers.Add(“Cache-Control

发布时间:2020-12-15 20:08:31 所属栏目:asp.Net 来源:网络整理
导读:不知道这是否有意义,但为什么在我的http处理程序中添加代码(响应一个返回一个json结果的ajax请求): 添加context.Response.Headers.Add(“Cache-Control”,“no-cache”); 造成错误,并说集成管道模式必须设置? 解决方法 @homestead,你做错了,你不能这样设置
不知道这是否有意义,但为什么在我的http处理程序中添加代码(响应一个返回一个json结果的ajax请求):

添加context.Response.Headers.Add(“Cache-Control”,“no-cache”);

造成错误,并说集成管道模式必须设置?

解决方法

@homestead,你做错了,你不能这样设置标题,微软说:

“The Headers property is only
supported with the IIS 7.0 integrated
pipeline mode and at least the .NET
Framework 3.0. When you try to access
the Headers property and either of
these two conditions is not met,a
PlatformNotSupportedException is
thrown.”

所以,如果你想设置标题,你必须使用context.Response.AddHeader(“headerName”,“someValue”);而代码应该成功添加标题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读