Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I am using an asp.net page that allows an upload of plain text files to the server. Everything works great, except every time i want to upload a file over 5 megs, i get a "cannot display webpage" error. this is the code I am using:

Dim file As HttpPostedFile
       Dim dateinfo As String
       Dim root As String
       Dim strfilename As String

       dateinfo = "(" & DateTime.Now.Date.Month & "-" & DateTime.Now.Date.Day & "-" & DateTime.Now.Date.Year & ")" & " [hr" & DateTime.Now.Hour & " min" & DateTime.Now.Minute & " s" & DateTime.Now.Second & "]"
       Try
           MkDir("C:\Inetpub\wwwroot\WriteMe\" & Session("ClearanceCode"))
       Catch
       End Try
       root = "C:\Inetpub\wwwroot\WriteMe\" & Session("ClearanceCode") & "\"
       strfilename = "C:\Inetpub\wwwroot\WriteMe\" & Session("ClearanceCode") & "\" & dateinfo & ".txt"

       'check that a file has been uploaded 
       If Request.Files.Count <= 0 Then
       Else
           'get the file data 
           file = Request.Files.Get(0)
           'check thats its not too big 
           If file.ContentLength > 102400000 Then
           Else
               If file.ContentType <> "text/plain" Then
               Else
                   'save file 
                   file.SaveAs(strfilename)
               End If
           End If
       End If

Edited by Robby
Stress is directly associated with programming. But if I keep moving on to new stresses, then I am doing my job correctly!
  • Moderators
Posted (edited)

I would change the IFs and add PostedFile to the Saveas

btw, do you really want to allow files of 100 Mb ?

If Request.Files.Count > 0 and  file.ContentLength < 102400000 and file.ContentType = "text/plain" Then
       file.PostedFile.SaveAs(strfilename)
end if

Edited by Robby
Visit...Bassic Software
Posted

I can answer your question:

 

Search for "machine.conig" on your HD (my file is under "C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\CONFIG\"

 

there is a line like this:

 

<httpRuntime executionTimeout="90" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100"/>

 

Change the "maxRequestLength" to a number you need. Standart this are 4MB (4096Byte)

 

The Timeout is in minutes...

 

Regards,

Stefan

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...