So i have been going at this for a few days and Im running into an issue. Im trying to make an ajax call that sends a byte[] to the controller in c#.
var data = { FtpUpload: self.Upload(), Attachment: self.Attachment() };
Base.ServiceCall("/Home/Upload", "post", data, true, function (response) {...}
self.Attachment() contains a property for the 'byte[]'. Im using this to read the byte array from the file which works as planned.
self.OnImageUpload = function (vm, evt) {
var file = evt.target.files[0];
var reader = new FileReader();
reader.onload = function () {
var attachment = {
...
Attachment: reader.result.split(',')[1]
};
self.Attachment(attachment);
}
reader.readAsDataURL(file);
};
When i do this with a 17mb file it works ok but when i do this with a 109mb file it throws a 500 error that says this.
[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
System.Web.Util.HttpEncoder.UrlDecode(Byte[] bytes, Int32 offset, Int32 count, Encoding encoding) +76
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +164
System.Web.HttpRequest.FillInFormCollection() +77
[HttpException (0x80004005): The URL-encoded form data is not valid.]
System.Web.HttpRequest.FillInFormCollection() +130
System.Web.HttpRequest.EnsureForm() +69
System.Web.HttpRequest.get_Form() +13
System.Web.HttpRequestWrapper.get_Form() +14
I have added the proper settings to my web.config to allow for larger files like so.
<system.web>
<httpRuntime targetFramework="4.6" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
</security>
</system.webServer>
Im not sure what else to do.