views:

1190

answers:

3

What is the maximum size a session variable can hold ? I am trying to store object in session variable, if object size is under 80 KB, then working fine and if the size is greater than 80 KB then on retereival I am getting exception.

How can I increase the session variable size?

This behaviour is on my production server, on the developement machine I can store big objects like above 500 KB etc..

I am implementing something like... http://aspalliance.com/1221_CodeSnip_Uploading_Multiple_Files_At_Once.all

here is my code..

private static int count = 0;
protected void Upload_Click(object sender, EventArgs e)
{
    for (int loopCount = 0; loopCount < count; loopCount++)
    {
        HtmlInputFile hif = (HtmlInputFile)Session["myupload" + loopCount];
        String filePath = Server.MapPath("~/AdvImages/") + loopCount.ToString() + "_" + hif.PostedFile.FileName;
        hif.PostedFile.SaveAs(filePath);
        Session.Abandon();
    }
}
protected void btnAdd_Click1(object sender, EventArgs e)
{
    Session["myupload" + count] = FileUpload1;
    count++;
}

Thanks

A: 

It depends on your php.ini file configuration.

Example memory_limit = 8M

I have tested to upload a 10megabyte file and throws Fatal error: Allowed memory size of 8388608 bytes exhausted.

With: memory_limit = 64M

There is no error.

Ismael
+1  A: 

Try to change requestLengthDiskThreshold to this:

<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="20000" useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="8192"/>
</system.web>

Googling says this helps:

http://www.netnewsgroups.net/group/microsoft.public.dotnet.framework.aspnet/topic32900.aspx http://channel9.msdn.com/forums/TechOff/104616-ASPNet-20-Uploading-file-exception/

Vitaly
A: 

From what i can think of, storing files in a session variable is a bad choice! Instead you can think of putting them into a temp location and then when upload is clicked you can put the to the real storage. Later on you can clear off the temp storage.

Bumble Bee