KnowDotNet NetRefactor

Net Sessions - Manage ASP.NET Session Variables

Using Strings for Session Variables

String Variables may well be the most widely used method for accessing Session Variables. They are also the nemisis that launched the idea behind Net Sessions. With the use of Strings as the means for accessing Session Variables comes an inherent potential for bug creation.

When you reference a Session Variable by the use of an embedded quoted string, as Session("VarName") in VB.NET, or Session["VarName"] in C#, you always run the risk of misspelling the name of the varaible. If you do that in
Setting (defining) a variable, you create a vairable that will never be referenced. Even worse, if you misspell the string in referencing the variable, you reference a variable that is not set (defined). Furthermore, not even the C# compiler will catch this error, and you will only find it in debugging at run-time when your application does not perform correctly.   Net Sessions is available for purchase or Free 30 Day Trial.  Click here to download.


If you are currently using embedded strings to access and set Session Variables, Net Sessions will help you in several ways to prevent the problems pointed out previously. First, Net Sessions shows all Session Variables in a dockable Tool Window.  See the description on the
Main Net Sessions Product Page.
so that you can automatically paste a reference to the desired variable by a double-click or other methods described in the Tool Window Topic. Additionally, you will see all Sessions Variables, that you have Set or Referenced, listed in the Tool Window in alphabetical order. This way, it will be fairly obvious if you have two variables spelled almost identically when there should have been only one variable. Finally, you can see a display of all Sessions Variables in a
Refresh Session Variables Dialog

Writing Add-Ins for Visual Studio .NET
Writing Add-ins for Visual Studio .NET
by Les Smith
Apress Publishing