2

What is the maximum size that ViewBag, ViewData, Tempdata can hold?

Hani Abidi
  • 25
  • 1
  • 6

2 Answers2

0

Actually Viewbag is dynamic, ViewData is a dictionary. So, the limit is untill run out of memory but the thought to dump huge data through viewbag is a bad idea. Instead use View Model.

0

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:

When to use ViewBag, ViewData, or TempData is ?

Bottom 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

Aravindan
  • 855
  • 6
  • 15