Trent Stewart
Trent Stewart

Reputation: 881

File Upload Causes Page To Hang

When attempting to upload a file of 35 megs, the website hangs.

I have set a break point on the server side before the File.SaveAs(path) command is even called.

I do a check on the server side to make sure the file is less than 20 megs, but it doesn't even reach this point. The web page just continues to load until I get a connection was reset error.

Upvotes: 0

Views: 1291

Answers (4)

peter
peter

Reputation: 15129

If you upload the file with simple HTTP-POST you need to wait for the whole file to be uploaded. You can't abort the upload earlier in the controller, only with web.config as cosset's answer suggests.

You could use maybe Flash to check the file size on the client already, don't know details about that though

Upvotes: 0

JJJCoder
JJJCoder

Reputation: 16986

Could this be a good chance to use async as shown here?

There is also an excellent article on async and await here.

Web.Config issues aside, a file that big is going to take some time. I would try not to block the current thread with such an action.

Upvotes: 0

Samiey Mehdi
Samiey Mehdi

Reputation: 9424

In Web.config in system.web :

<httpRuntime maxRequestLength="100000"/> 

100000kb =100 MB

Upvotes: 1

vborutenko
vborutenko

Reputation: 4443

Increase maxAllowedContentLength in web.config

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

Upvotes: 1

Related Questions