Click here to Skip to main content
15,884,628 members
Articles / Web Development / ASP.NET

No More Session Variable Misspellings

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
22 Jun 2011CPOL 8.6K  
I prefer to wrap my session variables like this:public class MySession { public string MyValue { get { return Convert.ToString(Session["MyValue"]); } set { Session["MyValue"] = value; } }}

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
29 Jun 2011Ziad J.khan
You can find a much more advanced version of this here:http://univar.codeplex.com[^]The version provided on the download page is soon to be deprecated by the upcoming version 2.0b however. The latter is available here instead:http://univar.codeplex.com/SourceControl/list/changesets[^]
Please Sign up or sign in to vote.
22 Jun 2011AspDotNetDev
This can be automated and streamlined with generics. First, create a SessionVariable class:public class SessionVariable{ private string VariableName { get; set; } private System.Web.SessionState.HttpSessionState Session { get; set; } public T Value { get ...
Please Sign up or sign in to vote.
23 Jun 2011#realJSOP 5 alternatives  
One way to guarantee uniqueness and avoid misspelling your session variable names
Please Sign up or sign in to vote.
29 Jun 2011Erich Ledesma
I came with another one. I happen to love Lambda expressions. The idea is to extend this base class:public class SafeSessionBase{ HttpSessionState _session; public SafeSessionBase(HttpSessionState session) { _session = session; } protected TResult...
Please Sign up or sign in to vote.
6 May 2019#realJSOP
This is an alternative for "No More Session Variable Misspellings"

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Unknown
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions