Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

asp.net - What is the maximum size a session variable can hold?

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 retrieval I am getting an exception.

How can I increase the session variable size?

This behaviour is on my production server, on the development 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try to change requestLengthDiskThreshold to this:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...