I am trying to send file to public IP. It works when file size is low but i want to send .BAK file which is large in size. While i am trying to send less than 20-30 MB of .BAK file its works but not more than 30MB.
I tried:- in Web.config
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
//this also tried
<system.web>
<httpRuntime maxRequestLength="2097152" />
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD324E38" />
</assemblies>
</compilation>
</system.web>
- I tried increased in the maximum upload file size in IIS
string publicAPI = "https://localhost:44350/Upload/";
var directory = new DirectoryInfo("D:\\Database");
var fileName = (from f in directory.GetFiles()
orderby f.LastWriteTime descending
select f).First();
Stream fileStream = System.IO.File.OpenRead(fileName.FullName); // here is error:ReadTimeout = 'fileStream.ReadTimeout' threw an exception of type 'System.InvalidOperationException'
try
{
using (var client = new HttpClient())
{
using (var formData = new MultipartFormDataContent())
{
formData.Add(new StreamContent(fileStream), "Mytic", fileName.Name);
var response = client.PostAsync(publicAPI, formData).Result;
if (response.IsSuccessStatusCode )
{}
else
{}
}
}
}
I am getting error in fileStream(error: ReadTimeout = 'fileStream.ReadTimeout' threw an exception of type 'System.InvalidOperationException') . How can i read Large file(.BAK)?
