Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > FileUpload size limited by requestLengthDiskThreshold

Reply
Thread Tools

FileUpload size limited by requestLengthDiskThreshold

 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      08-22-2006
Hello Phil,

Sorry for the late response since Walter has been absent due to some urgent
issue.

Yes, you're right. For ASP.NET 2.0 web application, if you set the
"RequestLengthDiskThreshold" the same value as "MaxRequestLengh", it will
behave like ASP.NET 1.1. Actually, the "RequestLengthDiskThreshold"
feature added in 2.0 is to address some potential memory issue when
uploading large files in ASP.NET application.

For your scenario, since you want to keep a reference to the uploaded file
content in session state, is this a frequent operation in your web
application? Even though we can set "RequestLengthDiskThreshold" ==
"MaxRequestLengh" to workaround the issue, I would not recommend this
because this will cause memory issue when there're large number of
fileupload requests and the file size is not very small.

Do you think it possible that we put a temp sub folder in our web
application and always explicitly save the HttpPostedFiles into that
folder as a temp file(adding some identity and timestamp into the temp
file's name). Thus, we can simply store he temp file name into SessionState
for late reference. Also, for this temp file folder, we can create a
background thread to closely monitoring it and delete those long idled
files(according the timestamp in file name).

Please feel free to let me know if there is any other information you
wonder.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


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


 
Reply With Quote
 
 
 
 
Phil Z.
Guest
Posts: n/a
 
      08-22-2006
The application works as you suggest -- we create a unique name and save the
file to a temp folder. The reason that we save the posted file to the
session is so that we can redirect the user to a confirmation page that
allows them to cancel and therefore not save the file (SaveAs() won't get
called).

I understand the possible memory problems that might ensue without limiting
each user's memory for the request. I expect that the posting of the file
to the web server is where most of the time is spent rather in the save, so
we'll likely change the application to save all files to the temp folder
before redirecting the user for any possible confirmations. This will allow
us to make use of the new memory management capabilities provided with the
RequestLengthDiskThreshold.

I'll run some tests to evaluate where best to set the threshold, but agree
that something significantly less than the 102400 that we're allowing for
the maximum request length should be used for the threshold.

Thank you --phil


"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:Ku6%(E-Mail Removed)...
> Hello Phil,
>
> Sorry for the late response since Walter has been absent due to some
> urgent
> issue.
>
> Yes, you're right. For ASP.NET 2.0 web application, if you set the
> "RequestLengthDiskThreshold" the same value as "MaxRequestLengh", it will
> behave like ASP.NET 1.1. Actually, the "RequestLengthDiskThreshold"
> feature added in 2.0 is to address some potential memory issue when
> uploading large files in ASP.NET application.
>
> For your scenario, since you want to keep a reference to the uploaded file
> content in session state, is this a frequent operation in your web
> application? Even though we can set "RequestLengthDiskThreshold" ==
> "MaxRequestLengh" to workaround the issue, I would not recommend this
> because this will cause memory issue when there're large number of
> fileupload requests and the file size is not very small.
>
> Do you think it possible that we put a temp sub folder in our web
> application and always explicitly save the HttpPostedFiles into that
> folder as a temp file(adding some identity and timestamp into the temp
> file's name). Thus, we can simply store he temp file name into
> SessionState
> for late reference. Also, for this temp file folder, we can create a
> background thread to closely monitoring it and delete those long idled
> files(according the timestamp in file name).
>
> Please feel free to let me know if there is any other information you
> wonder.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>



 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      08-23-2006
Thanks for your followup and let me know your progress on this.

Yes, uploading large file is both memory and time consuming at ASP.NET
layer, that's also why there are some ones who will use RAW ISAPI filter
for file uploading.

Anyway, if you meet any further problem later or any other information we
can provide, please feel free to let me know.

Good luck!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


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

 
Reply With Quote
 
spafa9 spafa9 is offline
Junior Member
Join Date: Oct 2007
Posts: 1
 
      10-03-2007
I have the same issue with large files. I also have the webconfig set up with the following.
<httpRuntime requestLengthDiskThreshold="8192"/>


This is the function I call it is an arraylist of filepaths so they can upload multiple files.


Public Function UploadFiles(ByVal FileInputList As ArrayList, ByVal TaskActivityID As String) As Boolean


Dim strUpLoadLoc As String
Dim ErrorUpload As Boolean
Dim intFilesUploaded As Integer
Dim strOrigFileName As String
Dim strAttFileName As String
Dim strExtension As String
Dim strContentType As String
Dim AttachID As String

intFilesUploaded = 0
strUpLoadLoc = ""
ErrorUpload = False

If (FileInputList.Count > 0) Then

'INSTANCIATING A NEW fileUpload FOR EACH ITEM IN THE FILEINPUTLIST ARRAY.
For Each FileInput As FileUpload In FileInputList

Try
strOrigFileName = System.IO.Path.GetFileName(FileInput.PostedFile.Fi leName)
strExtension = System.IO.Path.GetExtension(strOrigFileName)
strContentType = FileInput.PostedFile.ContentType
'INSERTING INTO THE ATTACHMENT TABLE
AttachID = clsData.InsertRecord(clsSQL.InsertAttachmentComman d(TaskActivityID, strOrigFileName, strContentType, strExtension, SessionManager.UserName, DateTime.Now.ToShortDateString), "CN_STR_TASK")
strAttFileName = AttachID + strExtension 'InsertAttachment(TaskActivityID, strOrigFileName, strContentType, strExtension, SessionManager.UserName, DateTime.Now.ToShortDateString)
clsData.UpdateRecord(clsSQL.UpdateAttachmentFileNa meCommand(strAttFileName, AttachID), "CN_STR_TASKMASTER")
strUpLoadLoc = System.Configuration.ConfigurationManager.AppSetti ngs.Get("AttachmentDir") & strAttFileName


FileInput.PostedFile.SaveAs(strUpLoadLoc) 'SAVING FILE TO SERVER
intFilesUploaded += 1 'INCREMENTING COUNT
ErrorUpload = False

Catch ex As Exception
clsCommon.LogError("wfTaskActivity", "UploadFiles", ex)
System.Diagnostics.Trace.Write(ex)
ErrorUpload = True
Response.Redirect("errorPage.aspx", False)
End Try
Next

FileInputList.Clear() 'CLEARING THE ARRAY

End If

Return ErrorUpload

End Function
 
Reply With Quote
 
TongDing TongDing is offline
Junior Member
Join Date: Jul 2008
Location: Miami FL USA
Posts: 1
 
      07-22-2008
Hi guys, I've been reading this thread which was very helpful. I'm currently setting "RequestLengthDiskThreshold" == "MaxRequestLengh" as temporary work around for user to upload files larger than 80K. The problem I'm encountering is that everything works fine when I run the application from VS on my development machine, I can see temporary files are been created. But when I deployed to the test web server, the uploading process stops at 80K, and no temproary files or 'upload' directory were created.
Can somebody help me with this problem please?

Thank you
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FileUpload control - file size detection E. Kwong ASP .Net 1 11-07-2006 07:42 PM
Have the size limitation about FileUpload ad ASP .Net 4 06-09-2006 01:50 PM
limited connectivity for limited users =?Utf-8?B?aG9yc2VmbHk=?= Wireless Networking 1 03-24-2006 05:17 PM
The size FileUpload can access? ad ASP .Net 4 01-22-2006 09:11 PM
FileUpload size and win2003 service pack1 ?? james ASP .Net 3 05-02-2005 06:16 AM



Advertisments