asp.net – 添加context.Response.Headers.Add(“Cache-Control”,“no-cache”);说IIS集成管道需要?

不知道这是否有意义,但为什么在我的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”);而代码应该成功添加标题.

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....