Hi Jack,
From your post title and first part, your question seems to "how to force
the connection close".
By default, HttpWebRequest.KeepAlive is true. So the connections should be
reused from one request to the next. And I don't think you need to
explicitly close the connection, just dispose the HttpWebRequest object.
Also, note that the server could also be closing the connection after
serving each request. Keep-alive can be set in the http request header, but
server can decide whether or not to reuse the connection.
Reusing connection is to improve performance. I don't think it's required
to maintain the login credential. As long as you are using the same
HttpWebRequest object, the credential should be used in subsequent
requests.
As your last question about "subsequent posts time out", I think this is
probably because the request size limit. If your server is written in
ASP.NET, the default maximum request size is 4MB. You can change this limit
in web.config:
<system.web>
<httpRuntime maxRequestLength="10240" /> <!-- change to 10MB -->
http://msdn2.microsoft.com/en-us/library/e1f13641.aspx
maxRequestLength:
Specifies the limit for the input stream buffering threshold, in KB.
This limit can be used to prevent denial of service attacks that are
caused, for example, by users posting large files to the server.
Also, you can use WebClient to do the post:
http://msdn2.microsoft.com/en-us/library/tt0f69eh.aspx
If my assumption is not the case, I think a repro project would be very
helpful for us to diagnose the issue quickly.
Sincerely,
Walter Wang (
[email protected], remove 'online.')
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.