Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   FileUpload size limited by requestLengthDiskThreshold (http://www.velocityreviews.com/forums/t364510-fileupload-size-limited-by-requestlengthdiskthreshold.html)

Phil Z. 08-15-2006 09:53 PM

FileUpload size limited by requestLengthDiskThreshold
 
After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot
access a closed file" errors when uploading. I found a number of post on
the subject and have since moved from using an Html File Input control to
using the new FileUpload control.

Previously, I had set the maxRequestLength attribute in the machine.config
file to allow 100MB uploads with success. In the v2.0 application I have
added an httpRuntime node to the web.config and have set
maxRequestLength=102400 as before. I also set the
requestLengthDiskThreshold value to 8192.

After doing this, files up to 8192KB in size were uploadable. I have now
found that the requestLengthDiskThreshold is the limiting value. By this I
mean that files that are smaller than the requestLengthDiskThreshold will
upload, while files larger than the requestLengthDiskThreshold setting
throw the "Cannot access a closed file" exception. This has proved true
with a number of different values entered for the threshold.

My understanding is that the requestLengthDiskThreshold value sets the
amount of the request that is cached in memory, and data beyond this value
is temporarily written to disk. Is this correct? Why am I finding that my
file upload size is limited by the requestLengthDiskThreshold setting?

Thanks much -- phil



John Timney \(MVP\) 08-15-2006 11:10 PM

Re: FileUpload size limited by requestLengthDiskThreshold
 
Your understanding of requestLengthDiskThreshold is correct, which suggests
that the underlying stream is being closed prematurely.

Out of interest try setting your maxrequestlength to be significantly larger
than your max file size expected and see if the problem goes away.

Regards

John Timney (MVP)


"Phil Z." <philz@noemail.noemail> wrote in message
news:OharYVLwGHA.1956@TK2MSFTNGP02.phx.gbl...
> After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot
> access a closed file" errors when uploading. I found a number of post on
> the subject and have since moved from using an Html File Input control to
> using the new FileUpload control.
>
> Previously, I had set the maxRequestLength attribute in the machine.config
> file to allow 100MB uploads with success. In the v2.0 application I have
> added an httpRuntime node to the web.config and have set
> maxRequestLength=102400 as before. I also set the
> requestLengthDiskThreshold value to 8192.
>
> After doing this, files up to 8192KB in size were uploadable. I have now
> found that the requestLengthDiskThreshold is the limiting value. By this
> I mean that files that are smaller than the requestLengthDiskThreshold
> will upload, while files larger than the requestLengthDiskThreshold
> setting throw the "Cannot access a closed file" exception. This has
> proved true with a number of different values entered for the threshold.
>
> My understanding is that the requestLengthDiskThreshold value sets the
> amount of the request that is cached in memory, and data beyond this value
> is temporarily written to disk. Is this correct? Why am I finding that
> my file upload size is limited by the requestLengthDiskThreshold setting?
>
> Thanks much -- phil
>




Phil Z. 08-15-2006 11:38 PM

Re: FileUpload size limited by requestLengthDiskThreshold
 
Thanks for the response. I have the maxRequestLength set to 100MB (102400)
and have experienced this behavior with 3 different files, one at about 6MB,
one at about 10MB, and one at about 45MB, all well less than the 100MB
maxRequestLength. In each case if the requestLengthDiskThreshold is set to
less than the file size it fails, and if it's more than the file size it
succeeds.

It makes me wonder if the worker process is unable to save to disk for some
reason... I ran filemon during one test and it did not reveal any problems.


"John Timney (MVP)" <x_john@timney.eclipse.co.uk> wrote in message
news:rtudncXoc-PryX_ZnZ2dnUVZ8qGdnZ2d@eclipse.net.uk...
> Your understanding of requestLengthDiskThreshold is correct, which
> suggests that the underlying stream is being closed prematurely.
>
> Out of interest try setting your maxrequestlength to be significantly
> larger than your max file size expected and see if the problem goes away.
>
> Regards
>
> John Timney (MVP)
>
>
> "Phil Z." <philz@noemail.noemail> wrote in message
> news:OharYVLwGHA.1956@TK2MSFTNGP02.phx.gbl...
>> After migrating an ASP.NET 1.1 application to 2.0 we were getting "Cannot
>> access a closed file" errors when uploading. I found a number of post on
>> the subject and have since moved from using an Html File Input control to
>> using the new FileUpload control.
>>
>> Previously, I had set the maxRequestLength attribute in the
>> machine.config file to allow 100MB uploads with success. In the v2.0
>> application I have added an httpRuntime node to the web.config and have
>> set maxRequestLength=102400 as before. I also set the
>> requestLengthDiskThreshold value to 8192.
>>
>> After doing this, files up to 8192KB in size were uploadable. I have now
>> found that the requestLengthDiskThreshold is the limiting value. By this
>> I mean that files that are smaller than the requestLengthDiskThreshold
>> will upload, while files larger than the requestLengthDiskThreshold
>> setting throw the "Cannot access a closed file" exception. This has
>> proved true with a number of different values entered for the threshold.
>>
>> My understanding is that the requestLengthDiskThreshold value sets the
>> amount of the request that is cached in memory, and data beyond this
>> value is temporarily written to disk. Is this correct? Why am I finding
>> that my file upload size is limited by the requestLengthDiskThreshold
>> setting?
>>
>> Thanks much -- phil
>>

>
>




Walter Wang [MSFT] 08-16-2006 05:42 AM

Re: FileUpload size limited by requestLengthDiskThreshold
 
Hi Phil,

I'm using following web form to test the FileUpload:

----8<----

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void UploadButton_Click(object sender, EventArgs e)
{
// Specify the path on the server to
// save the uploaded file to.
String savePath = @"c:\temp\uploads\";

// Before attempting to perform operations
// on the file, verify that the FileUpload
// control contains a file.
if (FileUpload1.HasFile)
{
// Get the name of the file to upload.
String fileName = FileUpload1.FileName;

// Append the name of the file to upload to the path.
savePath += fileName;


// Call the SaveAs method to save the
// uploaded file to the specified path.
// This example does not perform all
// the necessary error checking.
// If a file with the same name
// already exists in the specified path,
// the uploaded file overwrites it.
FileUpload1.SaveAs(savePath);

// Notify the user of the name of the file
// was saved under.
UploadStatusLabel.Text = "Your file was saved as " + fileName;
}
else
{
// Notify the user that a file was not uploaded.
UploadStatusLabel.Text = "You did not specify a file to upload.";
}

}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>FileUpload Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h4>Select a file to upload:</h4>

<asp:FileUpload id="FileUpload1"
runat="server">
</asp:FileUpload>

<br /><br />

<asp:Button id="UploadButton"
Text="Upload file"
OnClick="UploadButton_Click"
runat="server">
</asp:Button>

<hr />

<asp:Label id="UploadStatusLabel"
runat="server">
</asp:Label>
</div>
</form>
</body>
</html>

---->8----

With following settings in web.config:

<httpRuntime maxRequestLength="102400" />

I was able to upload files up to 60MB without problem.

I also have read some similar problems here:
http://channel9.msdn.com/ShowPost.aspx?PostID=106570

I guess you're reading directly from the stream? Could you please post your
code listing here? Thanks.

MaxRequestLength: limits the size of incoming requests, which limits the
size of the uploaded file.

RequestLengthDiskThreshold: controls whether the request is temporarily
stored in memory or on disk while being processed.

If you use FileMon to monitor the asp.net worker process, you will notice
when the uploaded file's size exceeds requestLengthDiskThreshold, a
temporary file gets created at such as:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\fileuploadsizelimit\ccca1291\f22cc828, if the file is smaller than
the RequestLengthDiskThreshold, the temporary file is not created.

So I guess your problem is asp.net was unable to create the temporary file
during uploads. But since you mentioned that you've already run FileMon and
it did not reveal any problems, the problem may exist somewhere before
asp.net trying to create the temporary file.

I want to take a look at your code before doing more research.

Sincerely,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Phil Z. 08-16-2006 04:02 PM

Re: FileUpload size limited by requestLengthDiskThreshold
 
Thanks Walter.

The code is distributed through our app a bit, but we retrieve the
HttpPostedFile from the FileUpload control and then send the HttpPostedFile
to another function that performs the save:

HttpPostedFile newPostedFile = FileUpload1.PostedFile;

string tempFile = @"\\CSCSRVWDC2DB4\data\SWIFT File Vault Temp\" +
docFileFullName;
newPostedFile.SaveAs(tempFile);


Note that a UNC path is used for the save as the web server is saving the
files to the database server. The exception is thrown on the SaveAs() line.

More information: I examined CREATEs using FileMon and the temp files are
being created as described when the requestLengthDiskThreshold setting is
less than the uploaded file size. Actually, a file is also being created in
the final UNC destination, but the file has no size, and the exception is
thrown.

I have attached the FileMon output filtered for file CREATEs for a file
upload that failed.

If the file size is less than the requestLengthDiskThreshold setting the
upload is successful, and no temp files are created. If the uploaded file
size is greater than the requestLengthDiskThreshold setting, a temp file is
created as expected, and then a file with the correct name and no size is
created in the final UNC destination before the "Cannot access a closed
file" exception is thrown.

-phil

"Walter Wang [MSFT]" <wawang@online.microsoft.com> wrote in message
news:gHei9aPwGHA.2004@TK2MSFTNGXA01.phx.gbl...
> Hi Phil,
>
> I'm using following web form to test the FileUpload:
>
> ----8<----
>
> <%@ Page Language="C#" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <script runat="server">
>
> protected void UploadButton_Click(object sender, EventArgs e)
> {
> // Specify the path on the server to
> // save the uploaded file to.
> String savePath = @"c:\temp\uploads\";
>
> // Before attempting to perform operations
> // on the file, verify that the FileUpload
> // control contains a file.
> if (FileUpload1.HasFile)
> {
> // Get the name of the file to upload.
> String fileName = FileUpload1.FileName;
>
> // Append the name of the file to upload to the path.
> savePath += fileName;
>
>
> // Call the SaveAs method to save the
> // uploaded file to the specified path.
> // This example does not perform all
> // the necessary error checking.
> // If a file with the same name
> // already exists in the specified path,
> // the uploaded file overwrites it.
> FileUpload1.SaveAs(savePath);
>
> // Notify the user of the name of the file
> // was saved under.
> UploadStatusLabel.Text = "Your file was saved as " + fileName;
> }
> else
> {
> // Notify the user that a file was not uploaded.
> UploadStatusLabel.Text = "You did not specify a file to upload.";
> }
>
> }
> </script>
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head id="Head1" runat="server">
> <title>FileUpload Example</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <h4>Select a file to upload:</h4>
>
> <asp:FileUpload id="FileUpload1"
> runat="server">
> </asp:FileUpload>
>
> <br /><br />
>
> <asp:Button id="UploadButton"
> Text="Upload file"
> OnClick="UploadButton_Click"
> runat="server">
> </asp:Button>
>
> <hr />
>
> <asp:Label id="UploadStatusLabel"
> runat="server">
> </asp:Label>
> </div>
> </form>
> </body>
> </html>
>
> ---->8----
>
> With following settings in web.config:
>
> <httpRuntime maxRequestLength="102400" />
>
> I was able to upload files up to 60MB without problem.
>
> I also have read some similar problems here:
> http://channel9.msdn.com/ShowPost.aspx?PostID=106570
>
> I guess you're reading directly from the stream? Could you please post
> your
> code listing here? Thanks.
>
> MaxRequestLength: limits the size of incoming requests, which limits the
> size of the uploaded file.
>
> RequestLengthDiskThreshold: controls whether the request is temporarily
> stored in memory or on disk while being processed.
>
> If you use FileMon to monitor the asp.net worker process, you will notice
> when the uploaded file's size exceeds requestLengthDiskThreshold, a
> temporary file gets created at such as:
> C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
> Files\fileuploadsizelimit\ccca1291\f22cc828, if the file is smaller than
> the RequestLengthDiskThreshold, the temporary file is not created.
>
> So I guess your problem is asp.net was unable to create the temporary file
> during uploads. But since you mentioned that you've already run FileMon
> and
> it did not reveal any problems, the problem may exist somewhere before
> asp.net trying to create the temporary file.
>
> I want to take a look at your code before doing more research.
>
> Sincerely,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>






Phil Z. 08-16-2006 04:07 PM

Re: FileUpload size limited by requestLengthDiskThreshold
 
Thanks Walter.

The code is distributed through our app a bit, but we retrieve the
HttpPostedFile from the FileUpload control and then send the HttpPostedFile
to another function that performs the save:

HttpPostedFile newPostedFile = FileUpload1.PostedFile;

string tempFile = @"\\CSCSRVWDC2DB4\data\SWIFT File Vault Temp\" +
docFileFullName;
newPostedFile.SaveAs(tempFile);

Note that a UNC path is used for the save as the web server is saving the
files to the database server. The exception is thrown on the SaveAs() line.

More information: I examined CREATEs using FileMon and the temp files are
being created as described when the uploaded file size is greater than the
requestLengthDiskThreshold setting. Actually, a file is also being created
in the final UNC destination, but the file has no size, and the error is
thrown.

I have attached the FileMon output filtered for file CREATEs for a file
upload that failed.

If the file size is less than the requestLengthDiskThreshold setting the
upload is successful, and no temp files are created. If the uploaded file
size is greater than the requestLengthDiskThreshold setting a temp file is
created as expected, and then a file with the correct name and no size is
created in the final UNC destination before the "Cannot access a closed
file" exception is thrown.

-phil

"Walter Wang [MSFT]" <wawang@online.microsoft.com> wrote in message
news:gHei9aPwGHA.2004@TK2MSFTNGXA01.phx.gbl...
> Hi Phil,
>
> I'm using following web form to test the FileUpload:
>
> ----8<----
>
> <%@ Page Language="C#" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <script runat="server">
>
> protected void UploadButton_Click(object sender, EventArgs e)
> {
> // Specify the path on the server to
> // save the uploaded file to.
> String savePath = @"c:\temp\uploads\";
>
> // Before attempting to perform operations
> // on the file, verify that the FileUpload
> // control contains a file.
> if (FileUpload1.HasFile)
> {
> // Get the name of the file to upload.
> String fileName = FileUpload1.FileName;
>
> // Append the name of the file to upload to the path.
> savePath += fileName;
>
>
> // Call the SaveAs method to save the
> // uploaded file to the specified path.
> // This example does not perform all
> // the necessary error checking.
> // If a file with the same name
> // already exists in the specified path,
> // the uploaded file overwrites it.
> FileUpload1.SaveAs(savePath);
>
> // Notify the user of the name of the file
> // was saved under.
> UploadStatusLabel.Text = "Your file was saved as " + fileName;
> }
> else
> {
> // Notify the user that a file was not uploaded.
> UploadStatusLabel.Text = "You did not specify a file to upload.";
> }
>
> }
> </script>
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head id="Head1" runat="server">
> <title>FileUpload Example</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <h4>Select a file to upload:</h4>
>
> <asp:FileUpload id="FileUpload1"
> runat="server">
> </asp:FileUpload>
>
> <br /><br />
>
> <asp:Button id="UploadButton"
> Text="Upload file"
> OnClick="UploadButton_Click"
> runat="server">
> </asp:Button>
>
> <hr />
>
> <asp:Label id="UploadStatusLabel"
> runat="server">
> </asp:Label>
> </div>
> </form>
> </body>
> </html>
>
> ---->8----
>
> With following settings in web.config:
>
> <httpRuntime maxRequestLength="102400" />
>
> I was able to upload files up to 60MB without problem.
>
> I also have read some similar problems here:
> http://channel9.msdn.com/ShowPost.aspx?PostID=106570
>
> I guess you're reading directly from the stream? Could you please post
> your
> code listing here? Thanks.
>
> MaxRequestLength: limits the size of incoming requests, which limits the
> size of the uploaded file.
>
> RequestLengthDiskThreshold: controls whether the request is temporarily
> stored in memory or on disk while being processed.
>
> If you use FileMon to monitor the asp.net worker process, you will notice
> when the uploaded file's size exceeds requestLengthDiskThreshold, a
> temporary file gets created at such as:
> C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
> Files\fileuploadsizelimit\ccca1291\f22cc828, if the file is smaller than
> the RequestLengthDiskThreshold, the temporary file is not created.
>
> So I guess your problem is asp.net was unable to create the temporary file
> during uploads. But since you mentioned that you've already run FileMon
> and
> it did not reveal any problems, the problem may exist somewhere before
> asp.net trying to create the temporary file.
>
> I want to take a look at your code before doing more research.
>
> Sincerely,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>






Walter Wang [MSFT] 08-17-2006 06:17 AM

Re: FileUpload size limited by requestLengthDiskThreshold
 
Hi Phil,

Since you're saving the file to a network path, I guess you must be using
impersonating, right?

Again I've changed my test like yours to save to UNC path:

web.config:

<authentication mode="Windows"/>
<identity impersonate="true"/>

default.aspx:

private void SaveFile(HttpPostedFile file)
{
String savePath = @"\\server\temp$\uploads\";
String fileName = file.FileName;
int i = fileName.LastIndexOf(@"\");
if (i >= 0) fileName = fileName.Substring(i + 1);

savePath += fileName;

file.SaveAs(savePath);

UploadStatusLabel.Text = "Your file was saved as " + fileName;
}

protected void UploadButton_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
SaveFile(FileUpload1.PostedFile);
}
else
{
UploadStatusLabel.Text = "You did not specify a file to
upload.";
}
}

And it still works correctly.

Have you tried to save to local path?

From your attached filemon log, you're using IIS5 instead of IIS6, right?

Is it possible for you to create a simpler repro project and send it to me?
Thanks.


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


=?Utf-8?B?UGhpbCBaLg==?= 08-17-2006 04:07 PM

Re: FileUpload size limited by requestLengthDiskThreshold
 
> Since you're saving the file to a network path, I guess you must be using
> impersonating, right?


Yes, and we're using setreg:
<identity impersonate="true"
userName="registry:HKLM\SOFTWARE\SWIFT\identity\AS PNET_SETREG,userName"
password="registry:HKLM\SOFTWARE\SWIFT\identity\AS PNET_SETREG,password"/>

<authentication mode="None"/> (is this a problem?)

> Have you tried to save to local path?

I have, and the the behavior is the same. We still get the exception and
save a file with no size.

> From your attached filemon log, you're using IIS5 instead of IIS6, right?


I'm currently working on my development workstation which is running Windows
XP, so it's got IIS5.1. The app will be deployed under Windows 2003 server
and IIS6. You still can't run IIS6 under XP right?

> Is it possible for you to create a simpler repro project and send it to me?
> Thanks.


I will work on this right away.

>
> Regards,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>


Walter Wang [MSFT] 08-18-2006 06:14 AM

Re: FileUpload size limited by requestLengthDiskThreshold
 
Hi Phil,

Thanks for your repro code. This behavior is expected because:

When the uploaded file's content is bigger than RequestLengthDiskThreshold,
a temporary file is created which is associated with current Request. When
you do a redirect, current Request is disposed and the file is closed.
Although you kept the HttpPostedFile in session, when you call SaveAs, it
tries to read from a closed file object, thus throws the exception.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Phil Z. 08-18-2006 12:08 PM

Re: FileUpload size limited by requestLengthDiskThreshold
 
Once I found that the redirect was causing the behavior, I figured that this
was the case. I guess that the simple asnwer would be to set the
RequestLengthDiskThreshold to be the same value as the MaxRequestLength and
then the entire uploaded file is kept in memory and no data is lost with the
redirect. This would mimic the behavior of ASP.NET 1.1, correct?

I'd rather figure out a way to take advantage of the new capability, but
we're using the redirect for user confirmations that are required...

-phil


"Walter Wang [MSFT]" <wawang@online.microsoft.com> wrote in message
news:hhfMj2owGHA.5368@TK2MSFTNGXA01.phx.gbl...
> Hi Phil,
>
> Thanks for your repro code. This behavior is expected because:
>
> When the uploaded file's content is bigger than
> RequestLengthDiskThreshold,
> a temporary file is created which is associated with current Request. When
> you do a redirect, current Request is disposed and the file is closed.
> Although you kept the HttpPostedFile in session, when you call SaveAs, it
> tries to read from a closed file object, thus throws the exception.
>
> Hope this helps. Please feel free to post here if anything is unclear.
>
> Regards,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>





All times are GMT. The time now is 04:21 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.