Reputation: 45801
I am using VSTS 2008 + C# + .Net 3.5 to develop ASP.Net. I want to dump all response headers returned to client for a specific aspx file. Any ideas how to do this easily?
I know how to use Response.Headers collection, but my confusion is where to enumerate to get the accurate response header? For example, if I enumerate in Page_Load, not all response headers could be enumerated, but if I enumerate after Response.Close, exception will be thrown.
Any advice?
EDIT1: Meeting with the following exception when using OnPreRender in VSTS 2008 debug mode (i.e. pressing F5 to debug)
{"This operation requires IIS integrated pipeline mode."}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
using (StreamWriter writer = new StreamWriter("dump123.txt", true))
{
writer.WriteLine(DateTime.UtcNow + " Response headers");
foreach (string item in HttpContext.Current.Response.Headers.Keys)
{
writer.WriteLine(item + " : " + HttpContext.Current.Response.Headers[item]);
}
}
}
thanks in advance, George
Upvotes: 3
Views: 4263
Reputation: 6733
[This may be old for the original question, but adding this answer for the benefit of newbees who might land here]
Change your web project's properties to use the local IIS for debugging as follows:
A detailed tutorial on the setup can be found HERE
Now when you hit F5, local IIS would be used for debugging and you would not get the platform not supported exception/complain about integrated pipeline mode required.
Upvotes: 0
Reputation: 755321
What about OnPreRender?? That's just before the page gets rendered, and after all hte postback processing has taken place. Everything should be in place by that time.
Marc
Upvotes: 3