ASP.net to realize the method of obtaining weather forecast according to city _ practical skills

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.