Wednesday, February 26, 2014

ASP.NET: How to detect whether Headers have been sent or not

In using ASP.NET, there isn’t a great way to know whether the Headers have been sent. One way to do this is to handle the PreSendRequestHeaders event then store the resulting value in context for the request like the HttpContext.Items collection. An example of this implementation is below.

You then simply call the static method Global.HeadersSent like the below.

No comments:

There was an error in this gadget