asp.net - DotNetZip download works in one site, not another -


edit - resolved: difference in "main" case download initiated via callback cycle, , in "test" case initiated through server side button click function. guess download request , callback cycle interfered each other, both stopping download , causing page become inactive (as described below). when rewired download on main page start submit instead of callback, did initiate download.

this in vs2013 ultimate, win7pro, vb.net, websites (not projects),iisexpress.

i built test site develop functionality creating openxml pptx , xlsx memorystreams , zipping , downloading them using dotnetzip. got work fine. merged code "main" site. both sites on same machine; can run test site , main site @ same time. main site processing more complicated, in terms of accessing , downloading more files.

however, zip , download function (below) works fine in test site, exact same code doesn't work in main site (with or without test site , running).

there's error trap (see below) around zip.save function download occurs no error shows up.

same overall behavior in chrome, firefox , ie11.

one peculiarity might clue when main site download fails, server side functionality "goes dead". local js functions work, app doesn't respond callbacks. when f5 on browser works again.

i did refresh on dotnetzip package in main site. zip object appears working properly, because generates error on duplicate file names.

i thought might download function written, however, works in test site. also, piece of main site non-zipped download of memory stream (included second code block below) , works fine.

i thought might data. kludged main site access, convert memorystream , download same file accessed , downloaded in test site. still main site download doesn't work.

when compare watch values on zip object in 2 sites, identical. length of wrkfs.contentstream identical in both cases. file names different, however, are: test_2efvg1thk5.xlsx (main) 6-18_12-46-28_0.xlsx (test) both legal file names.

edit: saved zip file disk main program, instead of trying download it, using this:

                wrkfilepath = "d:\filepath\test.zip"                 wrkzip.save(wrkfilepath) 

and worked fine. possibly isolates problem statement

            wrkzip.save(context.response.outputstream) 

edit: base on received here:

convert dotnetzip zipfile byte array

i used construct:

dim ms new memorystream wrkzip.save(ms) wrkbytes = ms.toarray() context.response.binarywrite(wrkbytear) 

to around zipfile.save(to context), , didn't work either; no download, no error message, , page goes dead. however, @ least can assume it's not problem zipfile.save.

at point i'm out of ways diagnose problem.

any suggestions appreciated.

here code works in test site not in main site.

    public sub zipanddownloadmemorystreams(byval context httpcontext) _ implements ihttphandler.processrequest     dim rtn string = ""      try         dim wrkar arraylist         wrkar = sc.contentarrayfordownload         if wrkar.count = 0             dim wrkstop integer = 0             exit sub         end if          dim wrkfs zipdownloadcontentpair         using wrkzip new zipfile             '----- create zip, add memory stream----------             n integer = 0 wrkar.count - 1                 wrkfs = wrkar(n)                 wrkzip.addentry(wrkfs.filename, wrkfs.contentstream)             next              context.response.clear()             context.response.contenttype = "application/force-download"             context.response.addheader( _                 "content-disposition", _                 "attachment; filename=" & "_xyz_export.zip")             '---- save context (initiate download)-----             wrkzip.save(context.response.outputstream)             wrkzip.dispose()          end using      catch ex exception         dim exmsg string = ex.message         dim wrkstop string = ""     end try end sub 

below non-zip download function works fine in main site. might possible convert zip content byte array , try download way, however, i'm not sure how work.

(see edit note above --- implemented version of below, i.e. try download byte array instead of directly zipfile.save(), however, didn't help; still doesn't download, , still doesn't give error message)

public sub downloadencryptedmemorystream(byval context httpcontext) _     implements ihttphandler.processrequest      dim wrkmemorystream new system.io.memorystream()      wrkmemorystream = sc.contentfordownload      dim wrkfilename string = sc.exportencryptedfilename      wrkmemorystream.position = 0     dim wrkbytesinstream byte() = new byte(wrkmemorystream.length - 1) {}     wrkmemorystream.read(wrkbytesinstream, 0, cint(wrkmemorystream.length))      dim wrkstr string = ""     wrkstr = encoding.utf8.getstring(wrkmemorystream.toarray())       wrkmemorystream.close()     context.response.clear()     context.response.contenttype = "application/force-download"     context.response.addheader("content-disposition", "attachment; filename=" & wrkfilename)     context.response.binarywrite(wrkbytesinstream)     wrkbytesinstream = nothing     context.response.end() 

(per note @ top of question): difference in "main" case download initiated via callback cycle, , in "test" case initiated through server side button click function. guess download request , callback cycle interfered each other, both stopping download , causing page become inactive (as described below). when rewired download on main page start submit instead of callback, did initiate download.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -