In this article we will try to understand how to make ASP.Net session objects Type Safe and override safety.
OOP
Object Oriented Programming - It just means reusability and making things more manageable.
All the architectures and technologies are just based on them or we can say derived from them.
ASP.NET Session
ASP.Net Session objects are basically used to store user-specific data, data which will be needed in more than one page related to a user.
Problem Statement
A company ABC organization is working on an E-Commerce website with around 5 developers. Each developer is working on one module.
- Problem 1
Say Developer 1 is working on a Book sale module and Developer 2 on a Magazine sale module. Now there is a strong possibility that Developer 1 will for example create a session variable say TotalPrice to store the TotalPrice of books (which keeps on updating as the end user purchases new books), and even Developer 2 creates the session variable with the same name since both are unaware about the other person's code.
- Problem 2
The Project Manager also wants to control the number of session variables used (because more session variables mean more memory consumed which results in lower performance.)
Solution
Make project architecture in such a way that for sessions there will be a central repository, if anybody wants to access or modify session values they go through that repository. For that create a Class SessionManager as follows:
public class ClsStateManagement
{
public string UserId
{
get
{
if (HttpContext.Current.Session["UserId"] == null)
return null;
return HttpContext.Current.Session["UserId"].ToString();

Sukesh MarlaPosted Aug 21, 2012, 11:12 PM
thanks akkiraju
Akkiraju IvaturiPosted Aug 21, 2012, 4:30 PM
You are right Sukesh S stands for System(s).
Sukesh MarlaeditedPosted Aug 21, 2012, 1:37 PMEdited Aug 21, 2012, 1:39 PM
Actually Sam according my knowldge S stands for system and calling OOPS means System developed using OOP methodology. Share if you have any thought.
Sam HobbsPosted Aug 21, 2012, 1:13 PM
No one can explain why the "S" is used in OOPS. It is Object Oriented Programming; there is no "S" at the end. For some reason some people are in the habit of using "OOPS" but there is no technical validity to it.
Sukesh MarlaPosted Aug 21, 2012, 12:22 PM
THANKS ARUN
arun kumarPosted Aug 21, 2012, 12:10 PM
wonderful thankyou.
Sukesh MarlaPosted Aug 15, 2012, 9:50 AM
thanks KRayudu
KRayudu VPosted Aug 15, 2012, 9:49 AM
excellent example....its very useful