Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in getting HTTP response custom Header

I am trying to add a custom Headers -> e1 HttpContext.Current.Response.AddHeader("e1","example of an exception"); to HTTP response in Page_Load method which works fine as I checked it in chrome developer tools.

U+25BC

The problem is if I am trying to write the same response using : HttpContext.Current.Response.Write(HttpContext.Current.Response.Headers["ALL_HTTP"].ToString()); it causes an PlatformNotSupportedException : This operation requires IIS integrated pipeline mode.

So the main question is how to read the added response header given I am using the inbuilt VS development server?
And it would be great if you can suggest some articles or book to know about properly using HTTP headers and verbs.

like image 908
Akina91 Avatar asked Dec 09 '25 06:12

Akina91


1 Answers

If you want to write that variable directly to the response then you can simply call this in your Page_Load. This will avoid the IIS integrated pipeline mode requirement.

Page.Response.Write(Request.ServerVariables["ALL_HTTP"]);

For learning I would concentrate on learning about HTTP and REST.

  • A fun primer on REST http://tomayko.com/writings/rest-to-my-wife
  • HTTP: The Definitive Guide by David Gourley (solid book that will guide you from the simple HTTP protocol into more advanced concepts)
  • HTTP 1.1 spec at http://www.w3.org/Protocols/rfc2616/rfc2616.html (dry read by the authority)
like image 76
kampsj Avatar answered Dec 11 '25 13:12

kampsj