473,657 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(HttpApplic ation r_objApplicatio n)
{

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}

protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}

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

Thanks in advance.

Nov 19 '05 #1
8 8134
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.Flus h();

-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(HttpApplic ation r_objApplicatio n) {

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}
protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}
My test page then spits out all request.headers and all
request.serverv ariables 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.Flus h();

-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(HttpApplic ation r_objApplicatio n) {

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}
protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}
My test page then spits out all request.headers and all
request.serverv ariables 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.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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(HttpApplic ation r_objApplicatio n)
{

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}

protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}

My test page then spits out all request.headers and all
request.serverv ariables 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.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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(HttpApplic ation r_objApplicatio n)
{

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}

protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}

My test page then spits out all request.headers and all
request.serverv ariables 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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eY******** ******@TK2MSFTN GP15.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.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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(HttpApplic ation r_objApplicatio n)
{

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}

protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}

My test page then spits out all request.headers and all
request.serverv ariables 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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eY******** ******@TK2MSFTN GP15.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.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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(HttpApplic ation r_objApplicatio n)
{

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}

protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}

My test page then spits out all request.headers and all
request.serverv ariables 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.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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(HttpApplic ation r_objApplicatio n)
{

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}

protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}

My test page then spits out all request.headers and all
request.serverv ariables 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.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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(HttpApplic ation r_objApplicatio n)
{

r_objApplicatio n.EndRequest += new
EventHandler(th is.EndRequest)
}

protected void EndRequest(obje ct sender, EventArgs e)
{
HttpResponse res = HttpContext.Cur rent.Response;
res.AddHeader(" MyTestHeaderVar ","MyTestVarVal ue");
res.Output.Flus h();
}

My test page then spits out all request.headers and all
request.serverv ariables 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
3719
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 with my SOAP request, so that the SOAP server will receive it and does some high level processing. Is it possible to add our own HTTP header fields in PHP? If i use the header() function to add the field into the HTTP header and it neither...
0
287
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) { r_objApplication.EndRequest += new EventHandler(this.EndRequest) }
0
3582
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 extra parameters in the header: id, login, and password. The request is supposed to look like this: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
2
4086
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 style="document"/use="literal", everything works fine - the header is added, message is serialized and all is ok. If the Web Service request is for an operation with style="rpc"/use="encoded":
9
2770
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 IS IMPOSSIBLE TO PROGRAMMATICALLY ADD A BUTTON TO A DYNAMICALLY CREATED PAGE. Or, to be more precise, why it is impossible to have an onClick sub respond to that button’s Click event. My main page has only one line:
0
1867
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 WSE 2.0. The Reference parameters are passed to me from a difference web service request and my application specific headers are of complex type. I tried to append the headers to RequestSoapContext.Envelope.Header . But
1
1236
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
2251
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 different ways to do things, but I have the issue of deploying to IIS6 servers. //get a reference NameValueCollection headers = HttpContext.Current.Request.Headers;
2
2092
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 after each HTTP request. The problem I’m having is that I’m trying to add a header line to the log files each time they are appended. For example if a new http request is made, a header will be added to each of the logs before the new standard...
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.