Hello,
I'm facing an issue with pass parameter contain a file from my project to another project ( services ), when I upload a file size 18 KB it's working fine. But when I upload a file or image size 2 MB or more, this error shown up >(413) Request Entity Too Large.
I'm trying since 2 days to solve this issue, and there is a lot of subjects and options but nothing work for my case
here is the web.config for "A" project which contain the controllers and views
<system.web><compilation debug="true" targetFramework="4.6.1" /><httpRuntime targetFramework="4.6.1" maxRequestLength="314572800" /><customErrors mode="On" defaultRedirect="" /><httpCookies requireSSL="false" /></system.web><system.webServer><httpProtocol><customHeaders><remove name="X-Powered-By" /><clear /></customHeaders></httpProtocol></system.webServer><system.serviceModel><bindings><basicHttpBinding><binding name="FirstService" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"><readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/></binding><binding name="SecondService" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"><readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/></binding></basicHttpBinding></bindings></system.serviceModel>
<endpoint address="http://localhost/Services/FirstService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFirstServiceWrapper"
contract="FirstServiceWrapperReference.IFirstServiceWrapper"
name="BasicHttpBinding_IFirstServiceWrapper" />
<endpoint address="http://localhost/Services/SecondServiceWrapper.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISecondServiceWrapper"
contract="SecondWrapperReference.ISecondServiceWrapper"
name="BasicHttpBinding_ISecondServiceWrapper" />
and here is the "Services" project web.config
<system.web><httpRuntime maxRequestLength="314572800" /><customErrors mode="Off" /><compilation debug="true" targetFramework="4.6.1" /><authentication mode="Windows" /></system.web><system.webServer><security><requestFiltering><requestLimits maxAllowedContentLength="2200000000" /></requestFiltering></security><httpProtocol><customHeaders><remove name="X-Powered-By" /><clear /></customHeaders></httpProtocol></system.webServer><system.serviceModel><bindings><basicHttpBinding><binding name="BasicHttpBinding_Second1" allowCookies="true" maxBufferPoolSize="2147483647777" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"><readerQuotas maxDepth="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/></binding></basicHttpBinding></bindings><client><endpoint address="http://xxx.xxx.xxx.xx:xxx/Second.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Second1" contract="SecondReference.xyz"
name="BasicHttpBinding_Second1" /></client>Controller
public ActionResult LoadFile()
{
try
{
if (Request.Files.Count > 0)
{
FileSendClass sender = new FileSendClass()
{
Id = 1,
FileName = Request.Files[0].FileName,
FileType = Request["Type"].ToString(),
CreatedBy = "ABC",
DocId = Convert.ToInt32(Request["docId"]),
FileBase64 = extensionHelper.ConvertInputStreamToBytes(Request.Files[0].InputStream),
Extension = Path.GetExtension(Request.Files[0].FileName)
//Note: Result of FileBase for file 3 MB is >> byte[3047054]
// I want max size is 10 MB !!
};
_SecondService.Process(sender);
}
}
catch (Exception ex)
{
ExceptionManager.HandleException(ex, MethodBase.GetCurrentMethod());
throw ex;
}
}public void UploadFile(FileSendClass file)
{
SecondServiceWrapperClient client = new SecondServiceWrapperClient();
try
{
var response = client.Process(file); /// Here I facing the error. compiler not going to service.. Exception ( 403 Request too large )
client.Close();
return response;
}
catch (Exception ex)
{
client.Abort();
ExceptionManager.HandleException(ex, MethodBase.GetCurrentMethod());
throw;
}
}I tried a lot of things like, but still I don't know where is the issue?? please if someone know help me.