According to this information given by the Asp.Net team What not to do in Asp.net no deberías usar
PreSendRequestHeaders in a managed HttpModule.
PreSendRequestHeaders and PreSendRequestContext
Recommendation: Do not use these events with managed modules.
The PreSendRequestHeaders and PreSendRequestContext events can be used with native IIS modules, but not with managed modules that implement IHttpModule. Setting these properties can cause issues with asynchronous requests.
This is precisely what I do in my Biblioteca de procesamiento de imágenes to ensure that the correct mime type is sent along with the response.
What would be the recommended alternative approach?
preguntado el 09 de septiembre de 13 a las 22:09
In a handler for
HttpResponse.AddOnSendingHeaders to subscribe a handler for that event.
This is essentially the same thing as
PreSendRequestHeaders, however it is handled fully within the ASP.NET pipeline so it doesn't have the same problems with the native/managed interface that
Si nos fijamos en el
HttpApplication pipeline on MSDN's ASP.NET App Life Cycle page you'll find
PreSendRequestContent events at the very bottom. Now that they're suggesting we not use these in managed
IHttpModules, the next closest event in the pipeline would be
EndRequest, which is deterministic unlike PreSendRequest* events.
I haven't been able to find any information on what the preferred practice is now for specifying response headers, but this will work for you.