This article gives an example of how ASP.net realizes the weather forecast according to the city. Share to everyone for your reference, specific as follows:
public void Getwetheaerbycity (string cityname) {
string city = CityName;
String mycity = Httputility.urlencode (city, System.Text.Encoding.GetEncoding ("GB2312"));
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create ("http://www.sina.com/ index.php?city= "+ cityname);
HttpWebRequest object gets GetResponse converted to HttpWebResponse
System.Net.HttpWebResponse response = Request. GetResponse () as System.Net.HttpWebResponse;
Through HttpWebResponse response. GetResponseStream () gets the output stream
stream str = response. GetResponseStream ();
StreamReader reader = new StreamReader (str, System.Text.Encoding.GetEncoding ("GB2312"));
String weathhtml = reader. ReadToEnd ();
Str. Close ();
Reader. Close ();
}
I hope this article will help you to ASP.net program design.