Akina91
Akina91

Reputation: 332

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.

Upvotes: 3

Views: 1193

Answers (1)

kampsj
kampsj

Reputation: 3149

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.

Upvotes: 2

Related Questions