I have done a C# dll and I'm using it from an old VB6 project.
I can correctly use it, but I have a problem.
In this dll, I make an http request to a server of mine, where I have set a wcf service. This code works well when I try to execute it from C#, but in VB6 it gives me the error System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.
I have already done what you can see here and this is my http request code:
private bool HTTPSgetRequest(string url, out string detail)
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "text/json";
httpWebRequest.KeepAlive = false;
Uri myUri = new Uri(url);
httpWebRequest.Method = "GET";
try
{
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
detail = streamReader.ReadToEnd();
}
if (httpResponse.StatusCode == HttpStatusCode.OK)
return true;
}
catch (Exception e)
{
detail = e.ToString();
}
return false;
}
So, I've added the keepAlive = false, but nothing changed, it still goes in the cath branch. Why? And what can I do now?