How to get weather detail using Web Services in ASP.NET?

In this article i have explained about how to get current weather details using ASP.NET and webservices. If you want to know whether detail of any city in the world, then you select your country name and the city name in the application finally click submit button your selected City detail Temperature and Humidity display in the page using web services. Check weather detail using Web Services in ASP.NET

Learn how to get weather detail using Web Services in ASP.NET?

Another one important question I saw in the forum section how to get weather detail of my city using web services. Here I explained how to get weather details of your city or any other city in the world using web services.
Here in this example project I keep the two drop down list one for country and another one for city. After you select country automatically that country cities are loaded in the second drop down list you can select city and click the submit button that all you will get your selected city weather details.

protected void Button1_Click(object sender, EventArgs e)
Label1.Text = "";
Label2.Text = "";
if ((DropDownList1.SelectedIndex == 0) || (DropDownList2.SelectedIndex == 0))
string xmlResult = null;
string url;
url = "" + DropDownList2.SelectedItem + "&CountryName=" + DropDownList1.SelectedItem + "";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader resStream = new StreamReader(response.GetResponseStream());
XmlDocument doc = new XmlDocument();
xmlResult = resStream.ReadToEnd();
XmlDocument xl = new XmlDocument();
XmlNodeList xnList = xl.SelectNodes("CurrentWeather");
foreach (XmlNode xn in xnList)
Label1.Text = "Temperature : " + xn["Temperature"].InnerText;
Label2.Text = "Humidity : " + xn["RelativeHumidity"].InnerText;
Label1.Text = "City Name Not match with our site!";
Label2.Text = "";

Source Code Detail:
Here with i have attached entire source code. Download it and try to check your city weather detail using web services.
Front End : ASP.NET
Code Behind : C#

Note : If you add any country in the first drop down list please check the exact country name in the XML file (placed in the same project source file name as Country.XML) and add it to the drop down list.

The Weather is not common for all cities it is different in all places, using this project we can check or test our city weather details. I hope this one is help you to find out weather report.


  • Get Weather Detail using Web Services (42806-101131-WeatherDetail.rar)
  • Comments

    Author: Ravindran24 Sep 2011 Member Level: Gold   Points : 0


    what ever cities name given by that only load in the dropdownlist.

    Guest Author: chaitanya03 Aug 2012

    I have to display weather information for today,tomorrow and day after tomorrow.
    Now i able to see present temperature only

    How to get weather information for tomorrow and day after tomorrow?

    Guest Author: Sudipta01 Oct 2012

    Hi... It is working fine.. Thanks for the post... Could any one tell me how to set default Country/city on DropDownList by help of login ip.

    Guest Author: Teckisttle20 Jun 2014

    Where can I download the source code again? There isn't any download link available. btw, this is a very helpful post. Keep up the good work.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: