May
7th | 2008

Why Should You Wrap Your ASP.NET Session Object

Posted by Shahar A |
Filed under .Net, ASP.Net, C# |

ASP.NET provides mechanisms for storing information for a single user session or across multiple sessions. This is done using the HttpSessionState and HttpApplicationState classes. The Page class has Application and Session attributes to provide access to current objects. The simple way to access them is as following:

if (Session["FirstName"] == null)
{
    LabelFirstName.Text = “FirstName”;
}
else
{
    LabelFirstName.Text = (string)Session["FirstName"];
}
if (Session["LastName"] == null)
{
    LabelLastName.Text = “LastName”;
}
else
{
    LabelLastName.Text = (string)Session["LastName"];
}


Continue Reading...
Apr
10th | 2008

How to Expose Your Collections Safely

Posted by Shahar A |
Filed under .Net, C# |

We use collections all the time. Many times we have to expose them to users of our classes. Lets look at this simple tree node class:
class TreeNode
{
private List<TreeNode> children = new List<TreeNode>();

public IList<TreeNode> Children
{
[...]


Continue Reading...

Search Dev102