Coffeehouse Thread

9 posts

Large File Uploads in ASP.NET 3.5

Back to Forum: Coffeehouse
  • User profile image
    pavone

    So my journey continues. I'm now trying to work on a webpage that needs to transfers files that may be as large as 10GB from one location to the other and ASP.NET 3.5 is not letting me do so with the FileUpload control. 

    After modifying web.config as follows:

    <httpRuntime executionTimeout="1000000000" maxRequestLength="2097151"/>

    I can upload files over 1GB, but it still fails when it comes to files at 4GB or higher. 

    Another thing I've noticed is that going into any event handler after browsing to a large file, takes a long time, even if the handler's code has nothing to do with the upload. I'm not really sure how the FileUpload control works, but it seems as if some copying is going on before it even gets to my handler, sure hope it's not putting all of that information in memory.

    Can anybody shed some light on this? thanks niners. 

  • User profile image
    blowdart

    , pavone wrote

    So my journey continues. I'm now trying to work on a webpage that needs to transfers files that may be as large as 10GB from one location to the other and ASP.NET 3.5 is not letting me do so with the FileUpload control.

    And with little wonder. When you send the file it's buffered in memory until it's complete. Do you have 10Gb of memory on your web server? Per user?

    You really need to find a better way - even if you had the memory HTTP file transfers don't checksum, or recover from dropped connections.

     

  • User profile image
    pavone

     It seems I'll have to rely on javascript then.. All I need is to copy from one place to the other. I could also spawn a process to robocopy from the webserver.. 

    Thanks blowdart, now I know FileUpload is definitely a big nono. 

  • User profile image
    blowdart

    , pavone wrote

     It seems I'll have to rely on javascript then.. All I need is to copy from one place to the other. I could also spawn a process to robocopy from the webserver.. 

    Oh are you sure you want to do that? Ideally you're running asp.net in a low priv account which can't do things like that. It would be safer to signal the transfer in some way and have a windows service listening, which has rights to transfer.

     

  • User profile image
    pavone

    Security is not much of an issue since this is an internal webpage where only a few people have access to it, these same people also have access to the web server anyways. 

    I'm still intrigued though, why does the file get uploaded without any code doing so after someone browses to a file and causes a postback?

    [edit]

    I just thought of something, is it because it needs to be loaded into memory otherwise it loses the state and the path to the file..

  • User profile image
    evildictait​or

    Uploading via a webserver is the wrong approach for internal users. HTTP uploads are usually pretty poor, and only work well with small files.

    If you need large file transfers, consider setting up an FTP server instead.

  • User profile image
    nfplee

    If you're using IIS 7+ then you also need to add the following to your web.config:

    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="2147482624" />
            </requestFiltering>
        </security>
    </system.webServer>
     

  • User profile image
    figuerres

    , pavone wrote

     It seems I'll have to rely on javascript then.. All I need is to copy from one place to the other. I could also spawn a process to robocopy from the webserver.. 

    Thanks blowdart, now I know FileUpload is definitely a big nono. 

     

    what about a file share on a server in the office ???

    or if for some reason you need to hide the location / provide some security then a desktop app that copies the files and you can rename them , encript them or whatever...

    a simple login profile can map a share so the user gets a pre-set drive letter to drop the files into.

    a really simple client app could be a "Drop Target" and use the current loggin of the user in the domain to then create the file on the server with some permissions, folder name and file name generated by the app.

    but only use an app if a simple copy will not work.

  • User profile image
    spivonious

    Yes, there are so many better solutions for this than using an internal web page.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.