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