Not sure if this makes sense, but why did adding the code on my http handler (responds to a ajax request returning a json result):
不确定这是否有意义,但为什么在我的http处理程序上添加代码(响应返回json结果的ajax请求):
adding context.Response.Headers.Add("Cache-Control", "no-cache");
添加context.Response.Headers.Add(“Cache-Control”,“no-cache”);
cause an error and say integrated pipeline mode has to be set?
导致错误并说必须设置集成管道模式?
1 个解决方案
#1
18
@homestead, you are doing wrong, you cannot set headers this way, microsoft says:
@homestead,你做错了,你不能这样设置标题,microsoft说:
"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."
“Headers属性仅受IIS 7.0集成管道模式和至少.NET Framework 3.0支持。当您尝试访问Headers属性时,如果不满足这两个条件中的任何一个,则抛出PlatformNotSupportedException。”
So, if you want to set headers you have to use context.Response.AddHeader("headerName", "someValue");
instead and your code should add the header successfully.
因此,如果要设置标头,则必须使用context.Response.AddHeader(“headerName”,“someValue”);相反,您的代码应成功添加标头。
#1
18
@homestead, you are doing wrong, you cannot set headers this way, microsoft says:
@homestead,你做错了,你不能这样设置标题,microsoft说:
"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."
“Headers属性仅受IIS 7.0集成管道模式和至少.NET Framework 3.0支持。当您尝试访问Headers属性时,如果不满足这两个条件中的任何一个,则抛出PlatformNotSupportedException。”
So, if you want to set headers you have to use context.Response.AddHeader("headerName", "someValue");
instead and your code should add the header successfully.
因此,如果要设置标头,则必须使用context.Response.AddHeader(“headerName”,“someValue”);相反,您的代码应成功添加标头。