Solved

Why should I not use HTTPContext Session State in my ASP .Net MVC applications?

Posted on 2014-02-26
2
582 Views
Last Modified: 2014-02-28
Hi:

I recall reading a couple of places that folks are discouraging the use of HTTPContext.Current.Session state in ASP .Net web applications.

Can someone explain some of the reasoning behind this recent trend?
Are there solid technical reasons for this?

Thanks,
JohnB
0
Comment
Question by:jxbma
2 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39891231
Are you sure they were referring to MVC and not MVC Web API? Not using session for Web API makes sense, but for a standard web application I don't see any real reason not to use session state.
0
 
LVL 22

Accepted Solution

by:
Snarf0001 earned 500 total points
ID: 39893585
There's a few reasons for it.

Main concern, is it's often really badly misused, where people are storing large objects (datatables etc) in the session.  For every user that goes to the site, all of the objects stored in their session are stored on the servers memory, so when misused, can quickly crash a system and cause a lot of bloat.

One of the other main concerns is in server farms / load balanced environments.
Where you can't be guaranteed that the server that served Page A, is going to be the same server that give the user Page B, hence the session won't have the same values.  There are some environments that provide "session persistence", where it will tie in a unique user to the same server for every request, but there are a lot more environments that don't.

If you don't have a load balancer / farm, then your main concern is misuse and server memory overhead.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now