0

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 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.