Solved

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

Posted on 2014-02-26
2
622 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 23

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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
How to set focus on a dynamic control 18 52
PDF Turn Look 7 34
How does this modal gets closed? 6 41
Datagridview column resizing 8 28
Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This video teaches users how to migrate an existing Wordpress website to a new domain.

734 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