如何转储在ASP.Net响应头 [英] how to dump response headers in ASP.Net

查看:166
本文介绍了如何转储在ASP.Net响应头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VSTS 2008 + C#+ 3.5的.Net开发ASP.Net。我想倾倒返回到客户端的一个特定的aspx文件的响应头。任何想法如何做到这一点很容易?

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?

我知道如何使用Response.Headers集合,但我的困惑就是枚举得到准确的响应头?例如,如果我在Page_Load中列举,并不是所有的响应头,可以列举,但如果我Response.Close后列举,会抛出异常。

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.

任何意见?

EDIT1:但以下情况除外VSTS中使用时,在preRender 2008年调试模式会议(即pressing F5调试)

Meeting with the following exception when using OnPreRender in VSTS 2008 debug mode (i.e. pressing F5 to debug)

{此操作需要IIS综合管道模式。}

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

推荐答案

关于preRender什么?这就是页面获取呈现之前,所有的回发兴田加工后已经发生。一切都应该由时间到位。

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.

马克

这篇关于如何转储在ASP.Net响应头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆