1

I was having trouble with the uploading of large files in .Net

I tried several references but to no avail. First issue was encountering error 404 when uploading files, I tried increasing the request limits maxAllowedContentLength and maxRequestLength which solved the issue. No more Error 404. But still, I have trouble uploading files more than 40Mb. No Endpoint calls recorded in Fiddler, not even an error or exception displayed in Visual Studio.

Here's a portion of my web.config:

    <system.web>
  <!-- Setting maxRequestLength to be much greater than default 4096 so that large data may be uploaded e.g. images, docs -->
  <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" maxRequestLength="204800000" executionTimeout="3600" />
</system.web>
<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral>
      <providerOption name="CompilerVersion" value="v4.0" />
      <providerOption name="WarnAsError" value="false" />
    </compiler>
  </compilers>
</system.codedom>
<system.webServer>
  <security>
    <requestFiltering allowDoubleEscaping="true">
      <requestLimits maxAllowedContentLength="2200000000" /> 
    </requestFiltering>
  </security>
</system.webServer>
<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <dataContractSerializer maxItemsInObjectGraph="6553600" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <bindings>
    <webHttpBinding>
      <binding maxReceivedMessageSize="6553600" />
    </webHttpBinding>
  </bindings>
</system.serviceModel>

Any help would be appreciated. Thanks

jfs
  • 39
  • 5
  • In Addition to having no response when uploading files more than 40Mb, I'm getting System Out of memory exception when uploading 100Mb files and up. – jfs Apr 06 '17 at 12:40
  • can u just go through this http://stackoverflow.com/questions/288612/how-to-increase-the-max-upload-file-size-in-asp-net – Ravi Kanth Apr 06 '17 at 12:42
  • Thanks for that @RaviKanth, But still I encounter the same problem. I'll take a look again, I might just missed something. – jfs Apr 06 '17 at 12:54
  • Unfortunately, Still cannot upload files more than 40Mb, I tried setting the limits to maximum of 1Gb. :( – jfs Apr 06 '17 at 13:37
  • Just to gather a bit of background - are you running on Azure, using on-premise IIS, or running locally with IIS Express? I also noticed that you'd tagged this question with visual-studio-lightswitch, if you're using LightSwitch which version is it and are you using the HTML or Silverlight client? – Chris Cook Apr 08 '17 at 17:40
  • Hi @ChrisCook I'm running it locally, and am using Silverlight client. Upon further investigation, I think the problem is now in writing the file on the server. There seems to be a problem in the streamwriter. Thanks for your replies. – jfs Apr 10 '17 at 04:49
  • In order to narrow down the cause of your issue, I'd suggest ticking on the option (Debug\Exceptions...) to break when all 'Common Language Runtime Exceptions are Thrown' to see where the out of memory exception initially occurs – Chris Cook Apr 10 '17 at 21:26
  • Yeah, I did that. There seems to be a problem when posting large files in my request as json. I'm now changing to post a multipart form. Thanks, @ChrisCook – jfs Apr 11 '17 at 03:13
  • I can't see why that wouldn't work - we're successfully using the MultipartFormDataStreamProvider to upload files well in excess of 100Mb. – Chris Cook Apr 14 '17 at 00:03
  • I actually don't know why it's not accepting my files when its larger than 40mb, Chunking the files is my only option now I guess. – jfs Apr 18 '17 at 07:02

0 Answers0