Getting error from web service method after publish "Maximum response size reached"

141 views Asked by At

Published GetDocument Web Method and it will return the File Name along with File Content, which is Base64 text of the File and it's working fine. But when we request more than 120MB file getting error Error: Maximum response size reached.

Actual:

For this I tried the below code in c#.

[WebMethod]
        public DocumentResponse GetDocument(string AuthTokenKey, string FileNameWithPath)
        {
            using (File_Information fs = new File_Information())
                return fs.GetDocumentResponse(AuthTokenKey, FileNameWithPath);
        }

private class File_Information
{

DocumentResponse ObjDocumentResponse;

public DocumentResponse GetDocumentResponse(string AuthTokenKey, string FileNameWithPath)
        {
if (ObjDocumentResponse == null)
                ObjDocumentResponse = new DocumentResponse();

FileInfo fileInfo = new FileInfo(FileNameWithPath);
 ObjDocumentImportFile.Add(new DocumentImportFile
                                            {
                                                FileName = StrFileName,
                                                FileContent = GetFileContent(fileInfo.FullName)
                                            });
            
            ObjDocumentResponse.DocumentImportFile = ObjDocumentImportFile;
            

            return ObjDocumentResponse;

}

private string GetFileContent(string name)
        {
            byte[] inputBytes = File.ReadAllBytes(name);
            return Convert.ToBase64String(inputBytes);
        }

}

After getting error of Maximum response size reached, I have modified the web.config file to accept/allowed the maximum response size.

<configuration>
  <system.web>
    <httpRuntime targetFramework="4.6.1" executionTimeout="3600" maxRequestLength="2048576000" requestLengthDiskThreshold="2048576000"  />
  </system.web>
</configuration>

Still getting the same Error.

Expecting: Require to return the File Content of Base64 text at least 500MB from the method.

Any help on this?

1

There are 1 answers

0
Bojjaiah On

I turn the setting into 350MB now working.

    <configuration>
  <system.web>
    <httpRuntime executionTimeout="3600" maxRequestLength="350000" />
  </system.web>
</configuration>

Require to check more than 350MB file with increasing timeout time.