HI
This is Srinivas,
I tried to getting web respone of url from Windows/console, code is working fine whle its runnning from appilication but returns exception while its running from EXE, same behaviuor follow in console appilication also.
The Error:- The underlying connection was closed: The connection was closed unexpectedly.
Code is :-
public void GetResponse()
{
string spp = "http://www.somewebsite.in/";
String result = GetPageContent(spp);
label2.Text = result;
}
public string GetPageContent(string FullUri)
{
try
{
HttpWebRequest WebRequestObject = (HttpWebRequest)HttpWebRequest.Create(FullUri);
// Request response:
WebResponse Response = WebRequestObject.GetResponse();
// Open data stream:
Stream WebStream = Response.GetResponseStream();
// Create reader object:
StreamReader Reader = new StreamReader(WebStream);
// Read the entire stream content:
string PageContent = Reader.ReadToEnd();
// Cleanup
Reader.Close();
WebStream.Close();
Response.Close();
// return PageContent;
return "Success";
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}
Please help me.
Rupesh KahanePosted Jul 20, 2018, 11:18 AM
Can you please elaburate liitle bit. Does you are accessing Web Api? Are you accessing any get method from that URL???
srinivasPosted Sep 19, 2018, 2:38 AM