|
I am doing a static function
The function used is as follows, the master should be familiar with this function.
public static string GetHttpPageTest (string urllink)
{
WebResponse response = null;
Stream stream = null;
StreamReader reader = null;
// try
// {
HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create (urllink);
//request.Timeout=1000;
response = request.GetResponse ();
stream = response.GetResponseStream ();
string buffer = "", line;
reader = new StreamReader (stream, System.Text.Encoding.UTF8);
while ((line = reader.ReadLine ())! = null)
{
buffer + = line + "\r\n";
}
Ranch
//}
// catch
// {
// return "$ False $";
//}
// finally
// {
if (reader! = null) reader.Close ();
if (stream! = null) stream.Close ();
if (response! = null) response.Close ();
//}
return buffer;
}
I run locally, the address on the internet can get the corresponding html
But when I upload this program to a server on the network, it doesn't work.
The following error appears, which master to show, thank you
The underlying connection has been closed: this remote name cannot be resolved.
Explanation: An unhandled exception occurred during the execution of the current web request. Check the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The underlying connection is closed: This remote name cannot be resolved. |
|