Session Variable Length

  • Thread starter Thread starter Guest
  • Start date Start date
I don't believe there are any size of length restrictions. Of course, if you
have lot's of users, and you are storing large objects in session, you need
to consider how much memory you have at your disposal.
 
FWIW - I've been storing about 2000 chars in one of mine on a certain page
and no problems so far.
 
length restrictions do not apply to the ASP.NET intrinsic objects like
session because they holds references. The limitation, as Marina pointed
out, is available memory on the machine.
 
We blew one the other day that was over 4,000 charcters. I thought I read somewhere that they were limited to 4kb. But I would like to confirm that.
 
Nope. Here's the proof of concept.

namespace WebApplication2
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
System.Text.StringBuilder str = new System.Text.StringBuilder();
for (int i = 1; i < 2000000; i++)
str.Append(i.ToString()).Append(",");

Session["Test"] = str.ToString();
TextBox1.Text = Session["Test"].ToString();
}
}

The size of the cache is only capped by memory. I have cached datasets as
large as 167 megs.
 
Back
Top