How to reset response headers in ASP.Net

I am using VSTS 2008 + C # + .Net 3.5 to develop ASP.Net. I want to discard all response headers returned to the client for a particular aspx file. Any ideas how to do this easily?

I know how to use the Response.Headers collection, but my confusion is where to list to get the exact response header? For example, if I list in Page_Load, not all header entries can be listed, but if I list after Response.Close, an exception will be thrown.

Any tips?

EDIT1: Encountering the following exception when using OnPreRender in VSTS 2008 debugging mode (i.e. when pressing F5 to debug)

{"This operation requires an integrated IIS 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

+3
2

OnPreRender?? , , , hte . .

+3

[ , , ]

- IIS :

  • ( node Solution explorer → OR node, ALT + )
  • ""
  • "" " IIS". IIS URL .

, F5, IIS , , / .

0

Source: https://habr.com/ru/post/1713566/


All Articles