By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,939 Members | 1,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,939 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.