Load Balancing ASP.NET Sites On Windows Server 2008

November 20th, 2009  |  Published in ASP.NET

I have been through this iteration twice now, so I wanted to share what I have found works for me in simple terms to get an ASP.NET site up and running on a set of load balance web servers.

I am not going to discuss the infrastructure site of this setup.  That would include setting up your servers with a heartbeat and configuring your ASP.NET sites.  The reason for this is that NLB strategies really vary from place to place depending on what hardware and network technology you are using.  Setting up IIS sites is frankly very straight-foward, and there is nothing you will do out of the ordinary here.

Lets focus on what we need to do to the application first to get it ready.

If your application uses any sort of Session State objects at all, it is wise to put your session information in SQL Server.  The reason behind this is that it really provides the best and most reliable source for keeping session information integrity between your two servers.  Besides that, since you are load balancing your application, you need a source for the session state that is available to ALL servers in the farm.

Start out by creating your ASPState database on your database server.  There is already a great article you can follow on how to do this here.

Its a rather long article, so let me outline the important stuff…

  1. Run the Aspnet_regsql.exe tool which is located in the systemroot\Microsoft.NET\Framework\versionNumber directory
  2. Go through the wizard to create the session database

Now that the ASPState database is created, we setup our ASP.NET application to use it.  In your web.config file, you will provide an entry that looks somewhat like the following…

<sessionState
mode=”SQLServer”
sqlConnectionString=”data source=SQL2005COR01;user id=ASPState;password=aspstate”
cookieless=”false”
regenerateExpiredSessionId=”true”
timeout=”30″
/>

<sessionState

mode=”SQLServer”

sqlConnectionString=”data source=yourDatabase;user id=dbuser;password=pwd”

cookieless=”false”

regenerateExpiredSessionId=”true”

timeout=”30″

/>

The documentation for what all these options do is located here..

http://msdn.microsoft.com/en-us/library/h6bb9cz9(VS.71).aspx

The sessionState block needs to go inside of the system.web section.

Now the next thing we need to do is to handle our View State between all the servers in our farm.  The ViewState is tied to the machine on which it is generated.  This information can be shared across servers, but it needs to be encrypted and decrypted.  Fortunately, this is very easy.

Go to the following site, make no changes to the default settings and let it generate the web config setting that you need for you.

http://aspnetresources.com/tools/keycreator.aspx

Now put this tag in the web config immediately following your sessionState information.

You are now ready to publish your application to each of the load balanced servers.

Could Not Load All ISAPI Filter For Site

November 20th, 2009  |  Published in ASP.NET

In IIS 7, should you get this message, you are quite possibly dealing with an error in your web.config file(s).  One way to know for sure is to set up your application under the Default Web Site (if you can) and try and view it from there.  It will give you a more specific error if its under a site that can in fact be started.  Its probably a syntax error like a missing tag or something of that nature.

There are other reasons for receiving this error as well.  Here are some additional links regarding this error…

http://forums.iis.net/t/1149051.aspx

http://www.eggheadcafe.com/software/aspnet/31530837/iis7-support-for-isapi-fi.aspx

Compelling WPF Resources

October 13th, 2009  |  Published in ASP.NET

Articles

Josh Smith On WPF And MVVM

http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

Josh Smith On Events And Commanding

http://joshsmithonwpf.wordpress.com/2008/03/18/understanding-routed-commands/

Shawn Wildermuth On Silverlight And MVVM

http://msdn.microsoft.com/en-us/magazine/dd458800.aspx

Tools

Kaxaml

http://www.kaxaml.com

XamlPad (Installed with Visual Studio)

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin

Other Resources

A special thanks to Matt Slay for providing me with these additional links…

Linq To SQL changes in 4.0

http://damieng.com/blog/2009/06/01/linq-to-sql-changes-in-net-40

And for those of you out there lucky enough to still be working with FoxPro, here is a linq provider for dbf’s.

http://linqtovfp.codeplex.com/

iPhone Won’t Connect To WPA Network

October 5th, 2009  |  Published in ASP.NET  |  17 Comments

I’ve had the annoying problem ever since I got my iPhone that I finally resolved today.  Basically, we have a corp0rate wireless network that is WPA secured.  My iPhone detects the network automatically, but when I put the TKIP password in, it says it can’t join the wireless network.

I tried to create a manual one under “Other”, but I kept getting the same error.

I couldn’t tell the iPhone to “forget” the network since I hadn’t joined it yet.

The secret here is to reset all your network settings by going to Settings / General / Reset.

In this menu, select “Reset Network Settings”.  Accept the warning and a reboot will happen.

Now, go back into wireless settings and even though your network might be picked up automatically, do not configure it.  Go to Other and set it up manually selecting the appropriate type of WPA authentication.  That should do it.

Now I can connect my iPhone to SharePoint.  Perfect.

The Provider Could Not Determine The Decimal Value

September 21st, 2009  |  Published in ASP.NET

I got this error this past week when working with a vendor who was exporting data in a .dbf (FoxPro).  It turns out that this can happen for a bunch of reasons, but most often its because there is an overflow in the field.  In other words, you may have a numeric field with a character in it.  Or maybe a date field with a bad date in it.

I’m sure that this oddity makes perfect sense to FoxPro, but it causes the OLEDB provider to throw up all over itself – in the form of an error similar to “The Provider Could Not Determine The Decimal Value”.

In fact, if you open up the dbf and look at its contents, you will most likely find the offending row and column contain ** for the value.  This would signify and overflow of some kind.

The solution is to either clean out the data in that column, or just don’t use the column.  As long as you don’t reference the column, all your CRUD operations will work fine.

Dude, What’s With Your Name?

August 14th, 2009  |  Published in ASP.NET  |  1 Comment

There seems to be much misconception about what my actual name is.  This is due partially to the fact that I have let it go on unaddressed for some time out of a compulsion to not have to explain myself over and over.

So before further proliferation occurs, here is the real story.

My name is Thomas Burke Holland.  The title of this blog reflects that.  I am known to everyone (mostly everyone) as Burke.  It’s what I’ve always been called.  Unfortunately, my first name proceeds me in terms of corporate email account, and therefore many people call me Thomas.

I will gladly answer to both, but the preference is Burke.

I take full blame for not setting the record straight earlier on, and for even introducing myself as Thomas to those in my professional circle thus exacerbating said misunderstanding.

So a huge apology to all, and an open admittance that this does constitute an odd set of circumstances, but needed to be cleared up.

Conditional Validation With ASP.NET Validators

July 28th, 2009  |  Published in ASP.NET  |  3 Comments

As a developer, i so loathe the task of form validation.  It’s a necessary evil for all developers at some point.  I just wish it weren’t so painful.

Fortunately, the asp.net validators will do at a very simple level just about all of the validation that you need on a form.

I am going to be focusing in this post on the custom validator.

My advice for getting on top of these ASP.NET validators is to do two things.  First and foremost, get to know javascript and how to use it to manipulate your form objects.  Secondly, get familiar with the asp.net validators client API.  ASP.NET validators will validate on the server, but lets be frank – you should not have to post back a page to validate it.  That is time consuming, resource intensive, and interrupts the users experience.  it’s also incredibly 2000 and late.

The custom validator is great, because you basically just pass it the name of a function where you will use javascript to do some validating.

Suppose we have a set of radio buttons, and a textbox.  If the person selects “Yes”, we want the textbox to be required.  If they select “No”, then the textbox is not required.  This is very easy to do with the custom validator.  Our HTML is going to look like this…

 

<asp:RadioButton ID="rbYes" runat="server" GroupName="TestGroup"
        Text="Yes" />
<asp:RadioButton ID="rbNo" runat="server" GroupName="TestGroup"
        Text="No" />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server"
        ClientValidationFunction="validatePage">*</asp:CustomValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />

 

Notice that we did not specify an error message in the custom validator.  The error message is what shows up in the validation summary (should you choose to use one).  The text attribute is simply what shows up on the page next to the control that fails validation.

Now we need a client function to validate the page.

 

function validatePage(source, args) {

            // get references to our page items
            var no = document.getElementById("rbYes");
            var yes = document.getElementById("rbNo");
            var txt = document.getElementById("TextBox1");

            // check to see if they checked yes.  if they did,
            // check to make sure the textbox is filled in with some
            // text.
            if (yes.checked)
                if (txt.value == "") {
                // setting the args.IsValid = false will tell our
                // custom validator that we failed validation
                args.IsValid = false;

                // optionally, we can set the error message portion
                // of the source object (the validator)
                source.errormessage = "You selected YES, so you must fill in the textbox";
            }
}

This will validate our form conditionally based on the selected radio button.  See how easy that was?  If you want to get fancy with your validation feedback, the asp.net validators fall a bit short.  As long as you are content to stick with the basics, they are pretty much all you will need in your validation toolbox.

Bing Week Wrap Up

July 17th, 2009  |  Published in ASP.NET  |  1 Comment

After 1 week of using Bing, I have gotten a good feel for the new search engine.  Here is my wrap up from Bing Week.

Things I Liked

I really like the look and feel.  It’s a much smoother experience compared to Google.  It’s easily just as fast as Google and the main search page loads quickly as well.

I liked the search history right inline with the page.  Being a developer and tech guy, I search mostly for programming issues, stack traces and error messages.  I frequently try several searches before I find what I am looking for.  It’s helpful to be able to backtrack through previous searches without having to look through history of searches (which is a pain for me in Google because they all look the same in the history bar) and without having to use the back button which never seems to behave like I think it should when moving between multiple searches and results.

A friend of mine pointed out that this is all well and good until your wife sees your search history – then it could be a problem.  I’m not holding my or others search morals against Bing.

I am a big fan of the preview that pops up when you mouse of the hover indicator.  It isn’t helpful all the time, but it does save you some unnecessary visits.

Things I did NOT like

There was only one thing that really bugged me.

For some reason or other (be it browser or Bing), whenever I would click out of the search box and back in, it wouldn’t let me backspace right away.  That was very annoying.

Final Thoughts

I really think that Bing is a great contender when considering it has to go up against Google.  I still feel like Google “knows” what I want while Bing is merely making a very educated guess.

Even though this is the case, the improved UI experience is enough to make me stick with Bing for the time being.  It wasn’t a clear winner, but it that’s the final split decision.

Bing Week!

July 13th, 2009  |  Published in ASP.NET

This week I am going to make a major technology shift as I resign myself to using only Bing for searches and abandoning Google.

Why make this change?

Google has owned this space for a long time and they have earned the credibility.  These days people use Google and they don’t even know why.

Therein lies the rub.

Search technology can be better – much better.  And how will we know when that happens if we won’t give that new technology the chance to impress us.

That’s why I’m inviting you to take the plunge and do Bing Week.  You never know – you might just starting “Binging” things instead of “Googling” them.

SharePoint PodShow 25

June 15th, 2009  |  Published in ASP.NET

I was listening to the SharePoint Pod Show today where they talked with Steve Smith about End User Adoption.

One of the things that he brought up was the tendency of IT to install SharePoint and then continue to micro-manage all content, access and site requests instead of focusing on things like disaster recovery and new development.

Unfortunately, I have had the experience of seeing this happen not once but twice in my SharePoint career.

Steve also spoke of “Legacy IT”, which I thought was a great description of those IT professionals who want to shield users from technology as much as possible, and are of the school of thought that if its tech – IT owns it and controls it end to end.

That rational simply doesn’t work with SharePoint.  Or rather – it completely amputates it at the knees so that it never becomes the platform that it was designed to be.

On the flip side of this are those folks who are too quick to throw technology at end users and expect them to be able to use it by reading a book or an MSDN article the way that we would as technology professionals.

The problem is that there is a medium somewhere between these two.  You don’t want to own SharePoint, but you don’t want to just give it to the users and expect it to be successful when people really start using it.

Too often I see people trying to throw SharePoint at a business problem that has no process defined.  As part of a SharePoint implementation, those processes need to be defined and IT needs to help users understand how they can leverage SharePoint to automate those processes.  If you automate complete chaos – you will have automated chaos.  Its still chaos.  And believe you me, SharePoint can quickly descend into a chaos of libraries, sites and permissions.

I think Heather Solomon made a good point when she said that SharePoint could benefit from some “simplification”.