I'm trying to connect to a fixed IP address (eg. http://10.60.903.50/TempFile) in order to retrieve one accii line of text in TempFile.
I try to read the information with this code:
string fullpath = " http://10.60.93.51/TempFile ";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(fullpath);
//req.KeepAlive = false;
HttpWebResponse res;
StreamReader sr;
string strResult = "";
res = (HttpWebResponse) req.GetResponse(); // <--- this line brings the error
sr = new StreamReader(res.GetResponseStream(), Encoding.ASCII);
txt_compTemp.Text = sr.ToString();
In the GetRespones, I get the error: "The underlying connection was closed: An unexpected error occurred on a receive. ". I read in an article that a possible solution would be to make the KeepAlive property of HttpWebRequest to False. It kept on giving me the error (That's why it's commented).
What else should I try?
Thank you,
Angel