473,321 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Adding header to request in HTTP Module

Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication)
{

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}

protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}

My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.

Nov 19 '05 #1
8 8108
If the page isn't buffered, then this should work. On an unrelated note (or
maybe it is?), you don't need to call:

res.Output.Flush();

-Brock
DevelopMentor
http://staff.develop.com/ballen
Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication) {

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}
protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}
My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.


Nov 19 '05 #2
If the page isn't buffered, then this should work. On an unrelated note (or
maybe it is?), you don't need to call:

res.Output.Flush();

-Brock
DevelopMentor
http://staff.develop.com/ballen
Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication) {

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}
protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}
My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.


Nov 19 '05 #3
Headers are not visible in a browser. They are part of an HTTP message that
is not in the HTML of the message.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

<ns******@aol.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication)
{

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}

protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}

My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.

Nov 19 '05 #4
Headers are not visible in a browser. They are part of an HTTP message that
is not in the HTML of the message.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

<ns******@aol.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication)
{

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}

protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}

My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.

Nov 19 '05 #5
ieHttpHeaders v 1.6 shows the http headers in IE.

http://www.blunck.info/iehttpheaders.html

It's quite convenient to use when debugging...and it's free!


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eY**************@TK2MSFTNGP15.phx.gbl...
Headers are not visible in a browser. They are part of an HTTP message that is not in
the HTML of the message.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
The sun never sets on
the Kingdom of Heaven

<ns******@aol.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication)
{

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}

protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}

My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.


Nov 19 '05 #6
ieHttpHeaders v 1.6 shows the http headers in IE.

http://www.blunck.info/iehttpheaders.html

It's quite convenient to use when debugging...and it's free!


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eY**************@TK2MSFTNGP15.phx.gbl...
Headers are not visible in a browser. They are part of an HTTP message that is not in
the HTML of the message.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
The sun never sets on
the Kingdom of Heaven

<ns******@aol.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication)
{

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}

protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}

My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.


Nov 19 '05 #7
Hi.

The ServerVariables collection returned by the Request object
only contains headers sent from the browser to the server.

Since your custom header was created on the server and then
sent to the browser (the opposite direction), your header will
never be added to the ServerVariables collection.

You should be aware of this if you ever plan to interrogate the
ServerVariables collection, expecting to find a custom header
you created in this way. It will never be there.

To check for custom headers added, use a tool like ieHttpHeaders v 1.6,
which shows the http headers in IE.

http://www.blunck.info/iehttpheaders.html

It's quite convenient to use when debugging...and it's free!


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

<ns******@aol.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication)
{

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}

protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}

My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.

Nov 19 '05 #8
Hi.

The ServerVariables collection returned by the Request object
only contains headers sent from the browser to the server.

Since your custom header was created on the server and then
sent to the browser (the opposite direction), your header will
never be added to the ServerVariables collection.

You should be aware of this if you ever plan to interrogate the
ServerVariables collection, expecting to find a custom header
you created in this way. It will never be there.

To check for custom headers added, use a tool like ieHttpHeaders v 1.6,
which shows the http headers in IE.

http://www.blunck.info/iehttpheaders.html

It's quite convenient to use when debugging...and it's free!


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

<ns******@aol.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Can you add a header to a request in an http module? I'm trying
unsuccessfully. Here's an example of my code:

public void Init(HttpApplication r_objApplication)
{

r_objApplication.EndRequest += new
EventHandler(this.EndRequest)
}

protected void EndRequest(object sender, EventArgs e)
{
HttpResponse res = HttpContext.Current.Response;
res.AddHeader("MyTestHeaderVar","MyTestVarValue");
res.Output.Flush();
}

My test page then spits out all request.headers and all
request.servervariables and my header is not anywhere. Does anyone
know what I'm doing wrong?

Thanks in advance.

Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ramas | last post by:
Hi, I am new to PHP scripting and i am trying to connect to a soap server (as mentioned below) using the SOAP extension comesup with PHP. Now my requirement is to add my HTTP header fields along...
0
by: nsyforce | last post by:
Can you add a header to a request in an http module? I'm trying unsuccessfully. Here's an example of my code: public void Init(HttpApplication r_objApplication) { ...
0
by: IT Drone | last post by:
I suspect what I want to do is simple, but after hours of googling I can't come up with an answer. I'm consuming a Java-based web service from an ASP.NET app. I want a request that includes 3...
2
by: Mike Fiedler | last post by:
On a client web services request, I have a SoapExtension that is adding a header to the message in the BeforeSerialize stage. If the Web Service request is for an operation with...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
0
by: Sanjaya | last post by:
Hi, I need to add application specific headers and reference parameter in the "ReplyTo" to my web service request as header elements. What is right way to do this? I'm using framework 1.1 with...
1
by: vivekvt | last post by:
-------------------------------------------------------------------------------- here is the code to the asp page that adds data to the access database! <html> <body> <% Dim recordsaffected
5
by: MikeB | last post by:
Hi, I had the following code running fine on my xp box. Then, I got a vista box and now I get a "PlatformNotSupportedException" when I try to add the header. I do know that now in IIS7 there are...
2
by: Devine123 | last post by:
Hi, I’m creating a perl script that takes incoming http/s requests, logs the standard input, output and error, before returning the output to the client. The input, output and error log is appended...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.