Redfield Weather Code now on GitHub

My code for Redfield Weather is now available on GitHub
https://github.com/erenken/redfieldweather

I had to move my secure connection strings out of the web.config and app.config files before I could post this online.  I decided to try Azure Key Vault as I am already hosting my site on Azure.  I have to say this was really easy to use and worked perfectly.  Azure doesn’t appear to have a UI for it yet in the portal, but the PowerShell commands were easy enough.  Using the Application Settings for the website in the Azure portal is a nice secure way for me to store my client ID, secret, and URI.

I am going to try to bring Key Vault to some work projects.

My project is also using some PHP code that I got from www.bordersweather.co.uk.  This is for a new lightening detection project I am a part of.  It use Time of Arrival (TOA) to calculate a lightening strike.  It is pretty cool stuff.  You can learn more about it at microsferics.com.  This code is not included in my project because I don’t own it.  I am trying to see if the developer is willing to post his code on GitHub and then I can link to it.  I have also added a Azure WebJob to my project so it will create the time-lapse GIF used by the PHP code.  You can see the time-lapse lightening map at http://www.redfieldweather.com/#/Maps and go down to the Lightning Timelapse microDLN section.

One of my goals is to replace the PHP code with a pure AngularJS and WebAPI site and do as much of it as I can in the AngularJS.  I am waiting for ASP.NET Core to be released before I start this project.  I will do it as a another re-write of the site.  I will also look at AngularJS 2.0 and Material design at the time.

Updated Weather Site

So I finally got around to updating my weather site, www.redfieldweather.com.  It has been something I have been wanting to do for a while.  I couldn’t update it for the longest time because my hosting provider didn’t want to install ASP.NET 4.0 until they made sure it was stable.  They just got my site switched over to ASP.NET 4.0 this month.

My new site has a what I think is a cool Silverlight control that shows the current weather conditions.  It is updated every 5 seconds so it should only be a few seconds behind what my weather station is showing at home.  Now my next big challenge is to rebuild my weather computer.  I get random crashes in the Virtual Weather Station software I use and that computer has been running pretty much non stop since I installed my weather station back in 2005.

I have completely changed the layout of the site as well so any comments would be greatly appreciated.

Current Weather Conditions Page

Shows the current weather conditions using the new Silverlight control and if there are any current weather alerts they will be right under the current conditions.  Today’s current forecast is displayed right under that and then some basic almanac data is displayed.

Forecast

Shows the 6 day weather forecast

Weather Maps

Displays weather maps of the area and region including lightning strike data

I am sharing the objects I have created with anyone who wants to use them.  You can download them from here:  RedfieldWeather.zip  These objects use the API-XML Feeds from Weather Underground.  These objects are not yet complete.  As I add more functionality and complete missing functionality I will update the file and my blog.  By downloading and using these objects you agree to not hold Demiurge Software LLC liable.  You use these objects freely and may redistribute them freely.  I may also include the source code in later versions.

I currently don’t have any sample code on how to use them, but I will be working on that for a future post.  Right now I just wanted to get the word out that the site has finally been updated.

UPDATED (3/14/2011):  I have fixed the link to the RedfieldWeather.zip file.

ASP.NET SQL Session State in a Web Farm

I found out the hard way that storing session in a SQL server takes a little more work then most of the books that I have read talk about.  Most articles don?t talk about what settings you should have when you are in a web farm.  This article will hopefully point you in the right directions and keep you from the headaches that I had.

One of the first things to check is the easiest to fix.  You will need to make sure you have a constant machine key between servers.  The machine key is used for encryption and decryption of cookie data.  Unless you set the machine key to a specific code on each machine they will use their own unique key, so when your connection switches from one server to the other server it can?t decrypt the data and you lose your session.

Microsoft has a couple articles on their site on how to create the machine keys and where to place them.  You can place this machine key in your machine.config or web.config files.

  • 312906 HOW TO: Create Keys by Using Visual C# .NET for Use in Forms Authentication
  • 313091 HOW TO: Create Keys by Using Visual Basic .NET for Use in Forms Authentication

The other fix is a little more complicated to change and is less likely to be a problem for everyone.  This problem happens when you add more web sites to one server then to the other server then you try to load balance two web sites.  What happens is that the application path for the web sites is different on each server.  For example on one server you have a web with an application path of \LMW3SVC2 and on the other server it has an application path of \LMW3SVC4.  The problem is IIS uses the application path to store the data, and if they don?t match you will lose your session.  You will have to synchronize the application path for the web sites on all your web servers in the web farm.

Microsoft has an article on this problem and how to fix it.  If you think this is your problem please check out this article.

  • 325056 PRB: Session State Is Lost in Web Farm If You Use SqlServer or StateServer Session Mode

When I was going through this we had both of these problems, and after running though these steps we are now using SQL session state on our web site, on a three server web farm.