4

Is there a cap or best practice with regards to how much data should be placed in the TempData dictionary?

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
Travis J
  • 81,153
  • 41
  • 202
  • 273

1 Answers1

2

Check this post that describes best practices when using TempData:

When to use ViewBag, ViewData, or TempData in ASP.NET MVC 3 applications

This one goes even further:

ASP.NET MVC: Do You Know Where Your TempData Is?

Bottom line is: By default, TempData is stored in the Session object. So the limit is the limit of your Session object. See this post for some insight.

Things to consider:

  • Generally, Session is stored in workerprocess memory eg.: in RAM....
  • To increase the amount of available memory, check the memory limit of your Application Pool in IIS.

For a more in-depth view of the Session object, check this doc at MSDN:

ASP.NET Session State Overview

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
  • Thank you for that link, I have read that post before, and numerous ones here on SO. However, none of them address the issue of memory usage by the TempData dictionary. I know when I am, and am not, "supposed" to use TempData and the implications of using it. – Travis J Apr 12 '12 at 20:53
  • That is one of the nested links from the first one you show. However, it does not cover how much storage in the dictionary is too much. Or really memory use at all in the dictionary except to state where it is being stored. – Travis J Apr 12 '12 at 20:55
  • 1
    That last post had a nice discussion on the actual implication of memory use. – Travis J Apr 12 '12 at 20:58
  • 2
    According to my provider, the memory limit of application pool is unlimited and automatically scales - so it's game on. :) – Travis J Apr 12 '12 at 21:41
  • 1
    The "Do You Know Where Your TempData Is?" is broken. Here is the fixed one: https://www.gregshackles.com/asp-net-mvc-do-you-know-where-your-tempdata-is/ – Lukas Sep 21 '22 at 14:51
  • Thanks @Lukas... updated the link. – Leniel Maccaferri Sep 21 '22 at 15:19