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”);而代码应该成功添加标题.

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...