Home > Mobile >  Getting "Not enough storage is available to process this command" when trying to download
Getting "Not enough storage is available to process this command" when trying to download

Time:09-15

Here is the full text of the error:

Server Error in Application.

Not enough storage is available to process this command. (Exception from HRESULT: 0x80070008)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Not enough storage is available to process this command. (Exception from HRESULT: 0x80070008)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[COMException (0x80070008): Not enough storage is available to process this command. (Exception from HRESULT: 0x80070008)]

[HttpException (0x80004005): An error occurred while communicating with the remote host. The error code is 0x80070008.]
System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)  3529243
System.Web.Hosting.IIS7WorkerRequest.FlushCore(Boolean keepConnected, Int32 numBodyFragments, IntPtr[] bodyFragments, Int32[] bodyFragmentLengths, Int32[] bodyFragmentTypes)  9898415
System.Web.Hosting.IIS7WorkerRequest.FlushCachedResponse(Boolean isFinal)  420
System.Web.HttpResponse.UpdateNativeResponse(Boolean sendHeaders)  476
System.Web.HttpRuntime.FinishRequestNotification(IIS7WorkerRequest wr, HttpContext context, RequestNotificationStatus& status)  125

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0

This happens when I try to download a 1GB zip file from my application. Here is the Visual Basic code that handles the download:

Dim path As String = Server.MapPath("uploads\" & dlFileName)
Dim file As New IO.FileInfo(path)
If file.Exists Then
    Response.Clear()
    Response.AddHeader("Content-Disposition", "attachment; filename=" & file)
    Response.AddHeader("Content-Length", file.Length.ToString())
    Response.ContentType = "application/octet-stream"
    Response.WriteFile(file.FullName)
    HttpContext.Current.ApplicationInstance.CompleteRequest()
End If

CodePudding user response:

Try this, the transmit file does not use memory to hold the file.

    Dim dlFileName As String = " whatever here "

    Dim path As String = Server.MapPath("uploads\" & dlFileName)
    Dim file As New IO.FileInfo(path)
    If file.Exists Then
        Response.Clear()
        Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
        Response.AddHeader("Content-Length", file.Length.ToString())
        Response.ContentType = "application/octet-stream"
        Response.TransmitFile(path)
        HttpContext.Current.ApplicationInstance.CompleteRequest()
    End If

Also, you have a bug/issue. You are using "file object" as a file name - you need to change this:

        Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)

Use file.name, not file.

The above should fix your memory issue.

  • Related