.net - Why is my File result filename corrupted IE9? -
i'm trying generate , return files users. file names contain unicode characters: aäa.pdf. when trying download them in ie 9 filename gets corrupted , download appears this:
in chrome works expected. return statement:
return file(filestream: stream, contenttype: system.net.mime.mediatypenames.application.octet, filedownloadname: mymodel.name + "." + pub.outputfiletype);
how can fix issue ie 9 has?
it seems no doable ie9, state namesv in comments. solved abusing browser feature: when requests /foo/fileÄÖ.pdf
, file returned, "filename" in url used.
so, created new route, targeted dynamic download , did in action:
if (request.browser.browser == "ie" && request.browser.majorversion == 9) { // filename comes route used, host/print/file.pdf response.clear(); response.addheader("content-disposition", "attachment"); response.contenttype = system.net.mime.mediatypenames.application.octet; response.charset = "utf-8"; response.headerencoding = unicodeencoding.utf8; response.contentencoding = unicodeencoding.utf8; byte[] buffer = new byte[4096]; int count = 0; while ((count = stream.read(buffer, 0, buffer.length)) > 0) { response.outputstream.write(buffer, 0, count); response.flush(); } response.end(); return null; } else { return file( filestream: stream, contenttype: system.net.mime.mediatypenames.application.octet, filedownloadname: compilation.name + "." + pub.outputfiletype); }
Comments
Post a Comment