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

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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?




.



Relevant Pages

  • Re: Is it possible to turn off "HTTP Keep-Alive" globally in app.config?
    ... You would just implement that class and have it create a new HttpWebRequest through reflection, either by getting the ConstructorInfo for HttpWebRequest, or by calling the Create method on the HttpRequestCreator instance through reflection. ... 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. ... SoapHttpClientProtocol has a protected method GetWebRequest(System.Uri ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Internet/Web classes in .NET/VC++...
    ... open a child window and request the result of the query from another page ... If I use the C++ WebClient class, I can successfully get the end results. ... queries, I cannot use the name-value form for sending data. ... So, I tried the HTTPWebRequest class (inherited from WebRequest, specific ...
    (microsoft.public.dotnet.languages.vc)
  • Re: forms auth, authenticate against already encrypted password?
    ... i actually tried using a WebClient implementation first, sending a POST request to login.aspx which handled Request.Formetc in the Page_Load event. ... i have tried it again using the HttpWebRequest class and now i can share the CookieContainers, ... programamtically send request to forms authentication protected webpage. ... you can consider share a cookie container ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • True asynchronous HttpWebRequest implementation with abort and timeout
    ... I'm tired of seeing all these asynchronous HttpWebRequest ... How do I implement an cancel method that aborts the request? ... private static void RespCallback(IAsyncResult asynchronousResult) ... // Read the response into a Stream object. ...
    (microsoft.public.dotnet.framework)
  • RE: WebResponse.GetResponseStream() exception
    ... programmatically request some web pages, ... Does this problem frequently occur when you use HttpWebRequest class to ... here is a test program which can programmatically request the ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework)