string result = "";
string url = "http://localhost:1759/textWeb/b.aspx";
result =exec_url(url);
Label1.Text = result;
public string exec_url(string url)
{
string result = "1";
WebRequest request = WebRequest.Create(url);
try
{
request.Timeout = 20000;//20秒超时
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream);
result = sr.ReadToEnd();
sr.Close();
resStream.Close();
}
catch
{
return "1";
}
return result;
}