I am sending a large video file (average file size of 50mb) to my server using HttpClient and PostAsync. I am getting an exception (see below for full exception details). I found a article that the maximimum file size that can be handled is 1mb or less is this true? If so, how can I increase the maximum file size?
{System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.IO.IOException: Error writing request ---> System.Net.Sockets.SocketException: The socket has been shut down at System.Net.WebConnection.EndWrite (System.Net.HttpWebRequest request, System.Boolean throwOnError, System.IAsyncResult result) [0x000cc] in <2016f34fb49d404d9e9f5c5e62749987>:0 at System.Net.WebConnectionStream.WriteAsyncCB (System.IAsyncResult r) [0x00013] in <2016f34fb49d404d9e9f5c5e62749987>:0 --- End of inner exception stack trace --- at System.Net.WebConnectionStream.EndWrite (System.IAsyncResult r) [0x000b8] in <2016f34fb49d404d9e9f5c5e62749987>:0 at System.IO.Stream+<>c.b__53_1 (System.IO.Stream stream, System.IAsyncResult asyncResult) [0x00000] in :0 at (wrapper delegate-invoke) System.Func
3[System.IO.Stream,System.IAsyncResult,System.Threading.Tasks.VoidTaskResult].invoke_TResult_T1_T2(System.IO.Stream,System.IAsyncResult) at System.Threading.Tasks.TaskFactory
1+FromAsyncTrimPromise1[TResult,TInstance].Complete (TInstance thisRef, System.Func
3[T1,T2,TResult] endMethod, System.IAsyncResult asyncResult, System.Boolean requiresSynchronization) [0x00000] in :0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in :0 at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x0036e] in :0 --- End of inner exception stack trace --- at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x00489] in :0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <df077aeeed724748974ac70c763795f3>:0 at System.Net.Http.HttpClient+<SendAsyncWorker>d__49.MoveNext () [0x000ca] in <e4f3fb4cf2054f718c1099b587ec6f1e>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <df077aeeed724748974ac70c763795f3>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <df077aeeed724748974ac70c763795f3>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <df077aeeed724748974ac70c763795f3>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <df077aeeed724748974ac70c763795f3>:0 at System.Runtime.CompilerServices.TaskAwaiter
1[TResult].GetResult () [0x00000] in :0 at TBSMobile.View.MainMenu+d__22.MoveNext () [0x00b96] in C:\Users\lawre\source\repos\TBSMobile\TBSMobile\TBSMobile\View\MainMenu.xaml.cs:1088 }
byte[] crVideoData;
if (!string.IsNullOrEmpty(crvideo))
{
crVideoData = File.ReadAllBytes(crvideo);
}
else
{
crVideoData = null;
}
try
{
if (!string.IsNullOrEmpty(crvideo))
{
var vidlink = "http://" + ipaddress + Constants.requestUrl + "Host=" + host + "&Database=" + database + "&Contact=" + contact + "&Request=Lqr9fy";
string vidcontentType = "application/json";
JObject vidjson = new JObject
{
{ "CAFNo", crcafNo },
{ "CAFDate", crcafDate },
{ "Video", crVideoData }
};
HttpClient vidclient = new HttpClient();
var vidresponse = await vidclient.PostAsync(vidlink, new StringContent(vidjson.ToString(), Encoding.UTF8, vidcontentType));
if (vidresponse.IsSuccessStatusCode)
{
await conn.QueryAsync<CAFTable>("UPDATE tblCaf SET LastSync = ? WHERE CAFNo = ?", DateTime.Parse(current_datetime), crcafNo);
}
}
else
{
await conn.QueryAsync<CAFTable>("UPDATE tblCaf SET LastSync = ? WHERE CAFNo = ?", DateTime.Parse(current_datetime), crcafNo);
}
}
catch(Exception ex)
{
Crashes.TrackError(ex);
}