Peter wrote
Can someone show how to use HttpContext.Current.Response.BinaryWrite in custom module? Because allways when I try to use it I get error in Internet Explorer that Resposne.Write can't parse .pdf file. In Fire Fox there is no error but module stops work and I have to refresh page. Furtheremore there are no errors on server side code. I am using DNN 4.9.0 and AJAX (with checked Suport Partial Rendering in Module Definition).
Can someone help me with this?
I tend to use HttpContext.Current.OutputStream.Write(byte[] myBytes, int startPosition, long length). In a nutshell you'd need to set the header, content type, content disposition (ie., filename) and optionally a Content-Range.
at minimum:
response.Clear();
response.AddHeader("Content-Length", "numberOfBytesHere");
response.ContentType = "application/octet-stream"; // of course, you could put anything here
response.AddHeader("Content-Disposition", "attachment; filename=myfile.pdf"); // again, any filename you want; caveat, can't have spaces otherwise firefox and some other browsers choke on it
response.OutputStream.Write(buffer, 0, length); // where buffer is your byte array, 0 is to start at position 0, length is total length to write out
response.Flush(); // flush output