Figured out the solution to it myself.
On Dec 8, 10:39 am, "bixbarton" <bixbar...@gmail.com> wrote:
> Running C# .NET 1.1
>
> I'm experiencing a weird oddity.
>
> We have a client app which access the webservice at
http://www.test.planningportal.gov.uk/soap/servlet/messagerouter
>
> If I start the client with no debugging it's fine.
>
> But if I start the client with debuggin on, when it Invokes a method on
> the webservice you get an exception saying "The underlying connection
> was closed: An unexpected error occurred on a send."
>
> I've searched online and all the results so far talk about how you need
> to override the WebRequest method and stick a KeepAlive = false in
> there.
>
> protected override WebRequest GetWebRequest(Uri uri)
> {
> HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
> request.KeepAlive = false;
> return request;
> }
>
> I've tried this, even accounting for the fact that the webservice is
> using SOAP. But still no joy.
>
> I also found another variation on the concept shown below;
>
> protected override WebRequest GetWebRequest(Uri uri)
> {
> WebRequest request = base.GetWebRequest(uri);
>
> if (requestPropertyInfo == null)
> {
> System.Type sType = request.GetType();
> requestPropertyInfo = sType.GetProperty("WebRequest");
> }
>
> if (requestPropertyInfo != null)
> {
> HttpWebRequest webRequest =
> (HttpWebRequest)requestPropertyInfo.GetValue(request, null);
> webRequest.KeepAlive = false;
> }
> return request;
> }
>
> But also this doesn't help. requestPropertyInfo ends up containing a
> null and so the GetValue never gets called.
>
> Does anyone have an idea?
>
> Krs
> Chris