Monday, March 26, 2012

Session Variable Length

Does anybody no the max length of data a session variable can contain ?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.
"BobTheHacker" <anonymous@.discussions.microsoft.com> wrote in message
news:826292E9-1529-494B-B61C-1332C7F30F64@.microsoft.com...
> Does anybody no the max length of data a session variable can contain ?
FWIW - I've been storing about 2000 chars in one of mine on a certain page
and no problems so far.
"BobTheHacker" <anonymous@.discussions.microsoft.com> wrote in message
news:826292E9-1529-494B-B61C-1332C7F30F64@.microsoft.com...
> Does anybody no the max length of data a session variable can contain ?
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.
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"D. Shane Fowlkes" <shanefowlkes@.h-o-t-m-a-i-l.com> wrote in message
news:OXC77ssLEHA.3016@.tk2msftngp13.phx.gbl...
> FWIW - I've been storing about 2000 chars in one of mine on a certain page
> and no problems so far.
>
>
> "BobTheHacker" <anonymous@.discussions.microsoft.com> wrote in message
> news:826292E9-1529-494B-B61C-1332C7F30F64@.microsoft.com...
>
We blew one the other day that was over 4,000 charcters. I thought I read s
omewhere 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.
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"BobTheHacker" <anonymous@.discussions.microsoft.com> wrote in message
news:FBFF147C-0534-460C-9297-0EF5D6E9DFA3@.microsoft.com...
> 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.

0 comments:

Post a Comment