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

标签 asp.net ajax iis caching

不确定这是否有意义,但为什么要在我的 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."

因此,如果您想设置 header ,则必须使用 context.Response.AddHeader("headerName", "someValue"); ,并且您的代码应该成功添加 header 。

关于asp.net - 添加 context.Response.Headers.Add ("Cache-Control", "no-cache");说需要 IIS 集成管道?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1294337/

相关文章:

iis - HTTP 错误 503 表示静态压缩已被禁用

javascript - 离开网站后,AJAX 页面加载/history.pushState 无法正常工作

ASP.NET Core URL 重写

javascript - JS 中的变量是否为空?谷歌地图 API

asp.net - 身份服务器 - 不记名 token 身份验证 - 如何跟踪失败的授权?

php - 如何在每 X 分钟内运行我的 php 代码?

javascript - 从 ajax 调用填充表单

asp.net - 在 IIS 中部署 Angular 6 应用程序后,我收到一个空白页面,没有错误

ASP.NET:每个用户缓存

asp.net - 为什么当我将 IncludeStyleBlock 属性设置为 True 时 CSS "gets lost"?