views:

1352

answers:

2

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):

adding context.Response.Headers.Add("Cache-Control", "no-cache");

cause an error and say integrated pipeline mode has to be set?

+5  A: 

@homestead, you are doing wrong, you cannot set headers this way, microsoft says:

"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."

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.

Cleiton
A: 

you need to use in this as mention in the above answer
Context.Response.AddHeader("name", "value");
Also Plz check this URL for understanding of Integrated vs. Classic Pipeline Modes

http://blogs.msdn.com/tmarq/archive/2007/08/30/iis-7-0-asp-net-pipelines-modules-handlers-and-preconditions.aspx

Muhammad Akhtar