Welcome to MSDN Blogs Sign in | Join | Help

Weather Forecast ASP.NET user control

I am posting source code for the weather report control that I am using on my Web site. It looks like this:

Weather forecast control preview

It fetches weather forecast data from a free XML Web service provided by US National Oceanic and Atmospheric Administration (NOAA). There is a lot of data there (wind speed and direction, humidity, precipitation, etc). I only used some of it. I believe the data is for US only so it won't work for every geographical location.

There is no copyright of any kind, feel free to use the code any way you see fit. If you don't like the code or markup, don't shoot me, I am only a C++ developer :-)

Updated version: http://blogs.msdn.com/mikhailarkhipov/archive/2006/06/12/628540.aspx

Published Thursday, August 12, 2004 11:18 PM by Mikhail Arkhipov (MSFT)

Comments

# re: Weather Forecast ASP.NET user control

Pretty cool stuff! Now all you need is to hook it up to USGS database for automatically determining lat/long from the city name:

http://geonames.usgs.gov/pls/gnis/web_query.gnis_web_query_form
Friday, August 13, 2004 5:35 AM by Dimitri Glazkov

# re: Weather Forecast ASP.NET user control

Cool stuff indeed - I wish I could put one of your weather images to show it!
Friday, August 13, 2004 9:27 AM by Mark

# re: Weather Forecast ASP.NET user control

In fact, icons are provided by NOAA as part of their Web service (very nice of them!).
Friday, August 13, 2004 9:42 AM by Mikhail Arkhipov (MSFT)

# re: Weather Forecast ASP.NET user control

I wanted to use this on a VB ASP.Net applications, but I can't just include the files, since it appears you can't mix VB and C# in the same project. I wanted to compile it into an assembly, but it doesn't look like Web Control libraries support ASCX user controls - just .CS classes. Any thoughts? Thanks!
Tuesday, August 31, 2004 8:50 AM by John

# re: National Weather (Web) Service

Tuesday, December 07, 2004 12:28 PM by Matt Powell

# NOAA Weather Forecast Web Service

Sunday, January 02, 2005 6:02 PM by Mikhail Arkhipov (MSFT)'s WebLog

# re: Weather Forecast ASP.NET user control

Just wanted to add another comment thanking you for your code and your benevolence to give it away. It's too bad NOAA doesn't provide real time weather data. They provide XML feeds for all of their weather stations (http://weather.gov/data/current_obs/) but many of them don't even have Latitude/Longitude coordinates -- what's the point of that? Anyway, this code gets me one step closer to a fully functional weather service.

Thanks,
Kevin Grigorenko
http://www.myplaceonline.com/
Thursday, April 14, 2005 6:33 PM by Kevin Grigorenko

# re: Weather Forecast ASP.NET user control

Well done! Thanks for sharing this.
Thursday, July 07, 2005 9:15 AM by Eric

# re: Weather Forecast ASP.NET user control

I need to use ur control how do i use it i have downloaded ur zip but help me in using the tool pls
Monday, September 05, 2005 7:24 AM by Advait

# re: Weather Forecast ASP.NET user control

Hi, I was wondering if there is something more to this. I have added your code and control to my solution. I dragged the control onto my form and made sure the control had the parameters you show in your README file but when I run the page nothing shows up. Any help is much appreciated. Also, thanks for the code!!!
Wednesday, September 07, 2005 11:34 AM by Brian Evans

# re: Weather Forecast ASP.NET user control

I am getting an Exception thrown in the ParseWeatherXML method. I do have a string value passed into this method but the exception is thrown anyway. Any help?
Wednesday, September 07, 2005 12:53 PM by Brian Evans

# re: Weather Forecast ASP.NET user control

The control stopped working on my own Web site as well. I guess NOAA might have changed something in their XML data. I'll try to debug when I get some spare time.
Saturday, October 15, 2005 11:29 PM by Mikhail Arkhipov (MSFT)

# re: Weather Forecast ASP.NET user control

I am posting this link here to help those who dont have this user control working atm. Maybe you can update the stream and such and that may fix your issues with this.

http://www.nws.noaa.gov/xml/index.php
Tuesday, December 13, 2005 6:41 PM by Tim Daley

# re: Weather Forecast ASP.NET user control

could u u tell me how i can use weather in my asp.net c# application.
Friday, February 24, 2006 7:41 AM by rakesh

# re: Weather Forecast ASP.NET user control

i m using weather asp.net usr control.

i m getting this error.

could u help in this way.


System.Net.WebException: The underlying connection was closed: The server committed an HTTP protocol violation. at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at Weather.gov.weather.www.ndfdXML.NDFDgen(Decimal latitude, Decimal longitude, String product, DateTime startTime, DateTime endTime, weatherParametersType weatherParameters) in C:\Inetpub\wwwroot\Weather\Web References\gov.weather.www\Reference.cs:line 38 at Weather.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\weather\webform1.aspx.cs:line 92


regards,


Rakesh
Tuesday, March 07, 2006 2:01 AM by rakesh

# re: Weather Forecast ASP.NET user control

Can someone clarify - does NDFD provide only FUTURE data or can I fetch historical weather data? What I'm really looking for in my application is ability to get historical data from days/weeks ago.
Wednesday, March 08, 2006 8:26 PM by OS

# re: Weather Forecast ASP.NET user control

hi,
Excellent stuff ..!
i would like to use this..!
But i just want to get wehter forecast information of gulf contries...So there is any webservice URL which give us weather forecast information of gulf coutries(whole world)...
any body having any info regarding this...plz reply me...

Thank u
Deepak
Saturday, April 01, 2006 1:42 AM by Deepak

# re: Weather Forecast ASP.NET user control

I'm in the middle of testing Weather forcast ASP.NET user control, the problem that gets me stumped is the follow (any ideas in resolving this issue)?

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The request failed with the error message:
--
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php">here</a>.</p>
<hr />
<address>Apache/2.0.46 (Red Hat) Server at weather.gov Port 80</address>
</body></html>

--.


Thank you!

j. smith
Friday, April 21, 2006 1:00 PM by j. smith

# re: Weather Forecast ASP.NET user control

I had this issue also.  I searched the entire project for the text "ndfdXMLserver.php" and found two lines in two documents that were pointing to URL's that have apparently moved.  Copy the URL "http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php" and replace the URL from the results you find from your search with the one copied.
That worked for me, but now the issue is the error "System.Net.WebException: The underlying connection was closed: The server committed an HTTP protocol violation." which was posted above with no resolution.  Microsoft explains this error is the result of increased security in the machine.config file.  The recommend adding a statement in there to remedy it, but that did not work for me.
Wednesday, May 10, 2006 1:25 AM by M. McMorrine

# re: Weather Forecast ASP.NET user control

I can't resist appreciating the owners of this blog. Good information. Well Done.

Bert Linert
http://www.humiditycontrolcenter.com
Thursday, May 11, 2006 7:12 AM by Bert Linert

# re: Weather Forecast ASP.NET user control

I'm testing Weather forcast ASP.NET user control and I am getting the following error. I did everything as per the instructions given in the Readme.txt file.

Server Error in '/Weather' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'DayWeatherData' could not be found (are you missing a using directive or an assembly reference?)

Source Error:



Line 46:             try
Line 47:             {
Line 48:                 DayWeatherData[] arrDayWeather;
Line 49:                 DateTime dtStart = new DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0);
Line 50:                


Source File: http://localhost/Weather/WeatherControl.ascx    Line: 48

Thanks,
Nookala
Thursday, June 08, 2006 9:46 AM by nookala

# re: Weather Forecast ASP.NET user control

Monday, June 12, 2006 3:49 PM by Mikhail Arkhipov (MSFT)

# Website Scripts &raquo; Mikhail Arkhipov (MSFT)&#8217;s WebLog : Weather Forecast ASP.NET user control

# Weather Web Service &#8212; Pending&#8230; : Perceptive Petal

Wednesday, March 26, 2008 4:33 PM by Weather Web Service — Pending… : Perceptive Petal

# Weather Web Service &#8212; Pending&#8230; : Perceptive Petal

Thursday, March 27, 2008 9:24 AM by Weather Web Service — Pending… : Perceptive Petal
New Comments to this post are disabled
 
Page view tracker