Solved

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

Posted on 2014-02-26
2
616 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to Office 1 39
Get sourcecode path 14 46
Asp.Net Session Question 2 33
How to force output to ascii 2 30
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

685 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