Re: Is it possible to turn off "HTTP Keep-Alive" globally in app.config?
- From: "Ryan K" <nospam@xxxxxxxxxx>
- Date: Sat, 14 Jul 2007 12:54:16 GMT
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]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:78CA539E-CA5F-436F-9D63-2E9301AE1030@xxxxxxxxxxxxxxxx
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]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"Morgan Cheng" <morgan.chengmo@xxxxxxxxx> wrote in message
news:1182842812.957049.165040@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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?
.
- Prev by Date: Re: plz advise!! user rights..
- Next by Date: Re: When is "volatile" used instead of "lock" ?
- Previous by thread: Re: C# COM entry point function
- Next by thread: a Mod b
- Index(es):
Relevant Pages
|