473,386 Members | 1,736 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,386 software developers and data experts.

Is it possible to turn off "HTTP Keep-Alive" globally in app.config?

Days ago, I post a question on how to make SoapHttpClientProtocol
instance make new TCP connection for each web service request. Now, I
found how.

SoapHttpClientProtocol has a protected method GetWebRequest(System.Uri
uri) which returns a WebRequest instance. Though MSDN doesn't make
clear statement. I experiment and prove that SoapHttpClientProtocol
use this method to create HttpWebRequest for HTTP request. So, I
override this protected method in subclass of SoapHttpClientProtocol.

protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = WebRequest.Create(uri.AbsoluteUri) as
HttpWebRequest;
request.KeepAlive = false;
request.UserAgent = "It is Morgan";

return request;
}

And it works as I wish.

Now, I am considering whether there is a way to config the application
to turn off HTTP Keep-Alive globally.
Is it possible?

Jun 26 '07 #1
4 11340

"Morgan Cheng" <mo************@gmail.comwrote in message
news:11**********************@a26g2000pre.googlegr oups.com...
Days ago, I post a question on how to make SoapHttpClientProtocol
instance make new TCP connection for each web service request. Now, I
found how.

SoapHttpClientProtocol has a protected method GetWebRequest(System.Uri
uri) which returns a WebRequest instance. Though MSDN doesn't make
clear statement. I experiment and prove that SoapHttpClientProtocol
use this method to create HttpWebRequest for HTTP request. So, I
override this protected method in subclass of SoapHttpClientProtocol.

And it works as I wish.

Now, I am considering whether there is a way to config the application
to turn off HTTP Keep-Alive globally.
Is it possible?
You might want to post to a MS.Public.dotnet.webservices or
MS.public.donet.framework.aspnet.webservices.

Jun 26 '07 #2
AFAIK it isn't possible, you have to override the class. If you can then I
would be interested to know as I have a requirement for this.

Kev

"Morgan Cheng" <mo************@gmail.comwrote in message
news:11**********************@a26g2000pre.googlegr oups.com...
Days ago, I post a question on how to make SoapHttpClientProtocol
instance make new TCP connection for each web service request. Now, I
found how.

SoapHttpClientProtocol has a protected method GetWebRequest(System.Uri
uri) which returns a WebRequest instance. Though MSDN doesn't make
clear statement. I experiment and prove that SoapHttpClientProtocol
use this method to create HttpWebRequest for HTTP request. So, I
override this protected method in subclass of SoapHttpClientProtocol.

protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = WebRequest.Create(uri.AbsoluteUri) as
HttpWebRequest;
request.KeepAlive = false;
request.UserAgent = "It is Morgan";

return request;
}

And it works as I wish.

Now, I am considering whether there is a way to config the application
to turn off HTTP Keep-Alive globally.
Is it possible?

Jun 26 '07 #3
Morgan,

I don't believe there is a way to turn it off globally, but you can make
it so that you can change the type returned by a call to WebRequest.Create
for http/https uris. You can set the value of the <webRequestModules>
element in the config file to point to a class that implements the
IWebRequestCreate interface. You would just implement that class and have
it create a new HttpWebRequest through reflection (this is a little brittle,
as it depends on implementation details), either by getting the
ConstructorInfo for HttpWebRequest, or by calling the Create method on the
HttpRequestCreator instance through reflection (preferred). Once you get
the HttpWebRequest back in your implementation of IWebRequestCreate, you
would just set the user agent and keep alive properties accordingly before
returning the new request.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Morgan Cheng" <mo************@gmail.comwrote in message
news:11**********************@a26g2000pre.googlegr oups.com...
Days ago, I post a question on how to make SoapHttpClientProtocol
instance make new TCP connection for each web service request. Now, I
found how.

SoapHttpClientProtocol has a protected method GetWebRequest(System.Uri
uri) which returns a WebRequest instance. Though MSDN doesn't make
clear statement. I experiment and prove that SoapHttpClientProtocol
use this method to create HttpWebRequest for HTTP request. So, I
override this protected method in subclass of SoapHttpClientProtocol.

protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = WebRequest.Create(uri.AbsoluteUri) as
HttpWebRequest;
request.KeepAlive = false;
request.UserAgent = "It is Morgan";

return request;
}

And it works as I wish.

Now, I am considering whether there is a way to config the application
to turn off HTTP Keep-Alive globally.
Is it possible?
Jun 26 '07 #4
If the server hosting the Web Service is under your control can't you just
shut if off in IIS (or equivalent)? Is there a downside to doing it there?

Ryan


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:78**********************************@microsof t.com...
Morgan,

I don't believe there is a way to turn it off globally, but you can
make it so that you can change the type returned by a call to
WebRequest.Create for http/https uris. You can set the value of the
<webRequestModuleselement in the config file to point to a class that
implements the IWebRequestCreate interface. You would just implement that
class and have it create a new HttpWebRequest through reflection (this is
a little brittle, as it depends on implementation details), either by
getting the ConstructorInfo for HttpWebRequest, or by calling the Create
method on the HttpRequestCreator instance through reflection (preferred).
Once you get the HttpWebRequest back in your implementation of
IWebRequestCreate, you would just set the user agent and keep alive
properties accordingly before returning the new request.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Morgan Cheng" <mo************@gmail.comwrote in message
news:11**********************@a26g2000pre.googlegr oups.com...
>Days ago, I post a question on how to make SoapHttpClientProtocol
instance make new TCP connection for each web service request. Now, I
found how.

SoapHttpClientProtocol has a protected method GetWebRequest(System.Uri
uri) which returns a WebRequest instance. Though MSDN doesn't make
clear statement. I experiment and prove that SoapHttpClientProtocol
use this method to create HttpWebRequest for HTTP request. So, I
override this protected method in subclass of SoapHttpClientProtocol.

protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest request = WebRequest.Create(uri.AbsoluteUri) as
HttpWebRequest;
request.KeepAlive = false;
request.UserAgent = "It is Morgan";

return request;
}

And it works as I wish.

Now, I am considering whether there is a way to config the application
to turn off HTTP Keep-Alive globally.
Is it possible?

Jul 14 '07 #5

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

Similar topics

1
by: Manjesh Gowda | last post by:
Hi all, I am maintaing a persistent HTTP connection using the "HTTP CONNECT" method , this works fine for many proxies like Squid, ISA , etc. But the iPlanet proxy disconnects the conneciton...
24
by: sinister | last post by:
After doing a websearch, it appears that it's OK to omit the "http:" to form a relative URL. Are there any pitfalls to this? For example, if there is a page http://www.domain1.com/page1.html...
7
by: ryan.fairchild | last post by:
Ok I basically am creating a container for a bunch of other <div> tags. But I want to make four jpegs/gif/whatever that goes in each corner so they look rounded. I thought this is how I would do...
1
by: mike | last post by:
regards: I write java code to simulate my machine as a HTTP server, what is the "MUST REPLY" HTTP response headers? In my small survey,I think there are 2 "MUST REPLY" HTTP response headers....
1
by: Domingo Aguirre | last post by:
I'm getting this error where I hadn't had a problem before. Prior to getting the error, I did change settings on the default web site. Could that cause this problem? How do I fix it? I've stop...
0
by: Joeyej | last post by:
Hi - I'm trying to move/use a web form (containing some javascript field checks) previously hosted on a Windows 2000 server. However, the FORM METHOD="post..." command in the form (shown below)...
1
by: gerr | last post by:
Visual studio 2003 "HTTP/1.1 500 Internal Server Error" when trying to create a new Asp.net site with Visual Studio 2003 on localServer/IIS 5.1. Anyone have any new solutions or urls to point me...
1
by: gerr | last post by:
Visual studio 2003 "HTTP/1.1 500 Internal Server Error" when trying to create a new Asp.net site with Visual Studio 2003 on localServer XP Pro/IIS 5.1. Everything worked fine prior to installing...
1
by: ashluvcadbury | last post by:
Hi all I have visual studio 2003 and also configured IIS.But not able to execute any web application. I am a beginner and all the small web applications I had made some days days ago were...
2
by: Tamer | last post by:
Hi! Is there a way to change the protocoll type through Javascript without reloading (or making a request from the webserver) via Javascript? for example: http://mydomain.com...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.