Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HttpWebRequest.KeepAlive doesn't create Connection header

Posted on 2009-05-11
6
Medium Priority
?
933 Views
Last Modified: 2013-11-08
Hello Experts,

I'm settings HttpWebRequest.KeepAlive to true, but when I hit a website that displays my headers, the Connection header is missing.  I've tried a few "header viewer" websites, but no luck.  When set to false, I was able to see the header "connection: Close".  what could explain this bizarre behavior?
0
Comment
Question by:sfun28
6 Comments
 
LVL 15

Expert Comment

by:oobayly
ID: 24365584
I can't replicate the issue here. I've use an Asp.Net page to return the headers as well as Wireshark to view the actual traffic.
http://www.wireshark.com/

Can you show the code you're executing?
0
 
LVL 15

Expert Comment

by:spprivate
ID: 24365586
What version of IIS are you using.
See if you have done this steps

http://technet.microsoft.com/en-us/library/cc772183(WS.10).aspx
0
 
LVL 1

Author Comment

by:sfun28
ID: 24366644
I'm not using IIS.  I have a WinForm app that tries to fetch a webpage.  Right now I have it fetch a page that shows me the headers I'm sending.  Here's an example of two pages I'm verifying against:
http://www.ericgiguere.com/tools/http-header-viewer.html
http://www.ioerror.us/ip/headers

Right now I have a class that inherits from WebClient.  It overrides GetWebRequest.  Please see the code snippet below.  I've verified that _keepAlive is true.

The strange part is that "Connection: Close" IS sent when _keepAlive is false.  I'm only using other sites to verify this.  I could try wireshark to be doubly-sure.
protected override WebRequest GetWebRequest( Uri address )
        {
 
            WebRequest request = base.GetWebRequest( address );
 
           
            HttpWebRequest httpRequest = request as HttpWebRequest;
 
            if ( httpRequest != null )
            {
 
                httpRequest.KeepAlive = _keepAlive;
                httpRequest.ProtocolVersion = _protocolVersion;
                httpRequest.CookieContainer = CookieContainer;
 
            }
 
            return request;
        }

Open in new window

0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 1

Accepted Solution

by:
sfun28 earned 0 total points
ID: 24772871
no response.  closing out.
0
 

Expert Comment

by:beanqa
ID: 26548637
I have the same issue.  Was this ever resolved?
0
 
LVL 1

Author Comment

by:sfun28
ID: 26549137
unfortunately not.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question