AaronS
AaronS

Reputation: 7713

Moving a session based asp.net application to an n-tiered architecture

I've inherited a large asp.net website that relies heavily on session information.

There is a back-end system that feeds it necessary information as needed through web services, but the application itself has no database, and everything is kept in session through a bunch of Data Objects which are accessed directly throughout the entire application.

I eventually want to try to migrate the application to a true N-Tier architecture, and start using a database instead of session based data objects.

My question is, what is a recommended path to get to the desired architecture?

I'm thinking that an initial step would be to create a Data Access Layer for accessing the data objects. Once this is in place, I would then be able to replace the data objects with a database.

The problem is that the session Data Objects are directly accessed from everywhere in the application. Because these objects are stored in session, you can directly set any of their properties without anything controlling the data. This is done throughout the whole application.

For example, say you have a customer Data Object stored in session. If you wanted to modify this customer, all you have to do is to set a local variable to the object stored in session. You could then update anything in the object just by setting mylocalvar.LastName = "blah"; Your session object is now updated without doing anything else.

Has anyone done anything like this before, and has any ideas on steps I could use to accomplish it?

*note: I'm not looking to off-load the session data, but to re-architect how the data is saved and accessed.

Upvotes: 1

Views: 1014

Answers (1)

Frank Tzanabetis
Frank Tzanabetis

Reputation: 2836

Sounds like a big job!

I guess the first step is to build an abstraction layer for your session information and refactor your code so that it depends on that instead of the session. Once you've done that, with your gui code now dependant only on the abstraction layer, you'll be able to pull out the session code out of the abstraction layer and replace it with data access code and your gui should be none the wiser.

Upvotes: 1

Related Questions