Using IE to validate that sticky sessions work with your Web app

Using Internet Explorer, how can you test and validate that your Web application works when sticky sessions and multiple Web servers?  Here’s how I do it:

While on call this weekend an issue arose where a user would get an error in the browser when their request was moved to different Web server in the farm. The user would authenticate against one Web server (establishing an online banking session and an aspnet session) but when the user made a 2nd request it was routed to a different Web server and that Web server was saying “Who the hell are you? I didn’t give you that aspnet session!”. and an error would be displayed to the user. This error/behavior was intermittent because the user will not always be directed to a secondary Web server (depending on load and/or load balancing configuration).

As a tester how can you recreate the issue every time when you are forced to use a domain name in the URL and using IPs in the URL isn’t an option? It can be done by using the hosts file on the browser’s machine (without a load balancer). Here is where the 2nd problem enters though: A hosts file change isn’t always recognized by the browser while it is open. However, you can force the browser to recognize changes in the hosts file by closing and restarting the browser. But in our case we have established an online banking session (via logon) and we need to keep it so we can’t close the browser. The trick…There is another way to force the browser to recognize the hosts file changes without closing it; here are the steps:

Step 1: Clear your browser cache and close all instances of the browser. If you don’t, the page you are requesting may be in cache it will read it out of the cache or go to the IP that was set before the hosts file change.

Step 2: Add the IP/hostname entries to the hosts file. The second entry will be commented out (see the bottom of this blog post to find out where your hosts file is located). For example:

Step 3: Using IE, navigate to and logon (because of your hosts file entry, you will be hitting Web server

Step 4: Change the entries in the host file to point to the 2nd Web server:


Step 5: Open a command window and run the command: nbtstat –R
(this purges and reloads the name cache)  

Step 6: Wait 3 minutes for IE to consume the change. Don’t ask me why but it refreshes at exactly 3 minutes.

Step 7: Conduct your next operation in IE (the request will be go to Web server

…and that’s how.

Hosts file locations for various Windows OS:
Windows XP = C:\Windows\System32\Drivers\Etc
Windows 2K = C:\Winnt\System32\Drivers\Etc
Win 98\ME = C:\Windows

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.