c# - ASP.NET MVC Error while downloading large file at Response.Flush() -


i use asp.net mvc 5. have function called download() in controller give user request files. have zip files in directory , deliver 1 zip file. these files big (e.g, need support ~100 gb download)

here attempt make function work

    public actionresult download()     {         var filename = path.getrandomfilename() + ".zip";         using (var zip = new zipfile(filename))         {             zip.compressionlevel = compressionlevel.bestcompression;             zip.usezip64whensaving = zip64option.always;              zip.adddirectory(server.mappath(directory));              var output = new memorystream();             //zip.save(output);             response.addheader("content-disposition", "attachment;filename=" + filename);             response.buffer = true;             response.bufferoutput = true;              zip.save(response.outputstream);             response.flush();              output.seek(0, seekorigin.begin);             return file(output, "application/zip", "compilation.zip");         }    } 

the files , directory constant, in client button.

so far i've tested files < 1 gb in total, works. however, exception gets thrown when files > 1 gb in total. i've got exception

not enough storage available process command.  (exception hresult: 0x80070008) source error:  line 50:                    response.flush(); 

i wonder, did miss configuration in mvc web.config settings or somewhere in iis manager settings? or purely implementation problem should implement zip files/directory , download zip file on fly method other way.

edit: verify, disk still have enough space don't know intuitively why complains not having enough storage.

edit 2: function works making response.bufferoutput = false; . there consequence in piece there cache anymore when function being called. might've cost performance when being called frequently. wonder if storage error because of buffer size.

ps: here stack trace, if helps:

[comexception (0x80070008): not enough storage available process command. (exception hresult: 0x80070008)] [httpexception (0x80004005): error occurred while communicating remote host. error code 0x80070008.]    system.web.hosting.iis7workerrequest.raisecommunicationerror(int32 result, boolean throwondisconnect) +3415687    system.web.hosting.iis7workerrequest.flushcore(boolean keepconnected, int32 numbodyfragments, intptr[] bodyfragments, int32[] bodyfragmentlengths, int32[] bodyfragmenttypes) +9790118    system.web.hosting.iis7workerrequest.flushcachedresponse(boolean isfinal) +413    system.web.httpresponse.updatenativeresponse(boolean sendheaders) +467    system.web.httpresponse.flush(boolean finalflush, boolean async) +152    system.web.httpresponse.flush() +23    system.web.httpresponsewrapper.flush() +14    poort80simpleapp.controllers.homecontroller.download() in d:\simpleapp\simpleapp\controllers\homecontroller.cs:50    lambda_method(closure , controllerbase , object[] ) +101    system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) +59    system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) +435    system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) +60    system.web.mvc.async.actioninvocation.invokesynchronousactionmethod() +76    system.web.mvc.async.asynccontrolleractioninvoker.<begininvokesynchronousactionmethod>b__39(iasyncresult asyncresult, actioninvocation innerinvokestate) +36    system.web.mvc.async.wrappedasyncresult`2.callenddelegate(iasyncresult asyncresult) +73    system.web.mvc.async.wrappedasyncresultbase`1.end() +136    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +102    system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethod(iasyncresult asyncresult) +49    system.web.mvc.async.asyncinvocationwithfilters.<invokeactionmethodfilterasynchronouslyrecursive>b__3d() +117    system.web.mvc.async.<>c__displayclass46.<invokeactionmethodfilterasynchronouslyrecursive>b__3f() +323    system.web.mvc.async.<>c__displayclass33.<begininvokeactionmethodwithfilters>b__32(iasyncresult asyncresult) +44    system.web.mvc.async.wrappedasyncresult`1.callenddelegate(iasyncresult asyncresult) +47    system.web.mvc.async.wrappedasyncresultbase`1.end() +136    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +102    system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethodwithfilters(iasyncresult asyncresult) +50    system.web.mvc.async.<>c__displayclass2b.<begininvokeaction>b__1c() +72    system.web.mvc.async.<>c__displayclass21.<begininvokeaction>b__1e(iasyncresult asyncresult) +185    system.web.mvc.async.wrappedasyncresult`1.callenddelegate(iasyncresult asyncresult) +42    system.web.mvc.async.wrappedasyncresultbase`1.end() +133    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +56    system.web.mvc.async.asynccontrolleractioninvoker.endinvokeaction(iasyncresult asyncresult) +40    system.web.mvc.controller.<beginexecutecore>b__1d(iasyncresult asyncresult, executecorestate innerstate) +34    system.web.mvc.async.wrappedasyncvoid`1.callenddelegate(iasyncresult asyncresult) +70    system.web.mvc.async.wrappedasyncresultbase`1.end() +133    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +56    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +37    system.web.mvc.controller.endexecutecore(iasyncresult asyncresult) +44    system.web.mvc.controller.<beginexecute>b__15(iasyncresult asyncresult, controller controller) +39    system.web.mvc.async.wrappedasyncvoid`1.callenddelegate(iasyncresult asyncresult) +62    system.web.mvc.async.wrappedasyncresultbase`1.end() +133    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +56    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +37    system.web.mvc.controller.endexecute(iasyncresult asyncresult) +39    system.web.mvc.controller.system.web.mvc.async.iasynccontroller.endexecute(iasyncresult asyncresult) +39    system.web.mvc.mvchandler.<beginprocessrequest>b__5(iasyncresult asyncresult, processrequeststate innerstate) +39    system.web.mvc.async.wrappedasyncvoid`1.callenddelegate(iasyncresult asyncresult) +70    system.web.mvc.async.wrappedasyncresultbase`1.end() +133    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +56    system.web.mvc.async.asyncresultwrapper.end(iasyncresult asyncresult, object tag) +37    system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult) +40    system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result) +38    system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +9742689    system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +155 


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -