0

I have pdf files in folder, I want user enable to download file, in MVC controller its quite simple as below

return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, filename);

but it does not work with Sitecore and throws following exception, can anyone give minimal example how it can be achieved.

OutputStream is not available when a custom TextWriter is used.

Thanks

3
  • It works good for me in sitecore 9. Did you try to change mimetype to System.Net.Mime.MediaTypeNames.Application.Pdf ? Do you have forceDownload=true in <mediaType name="PDF file" extensions="pdf"> node of config? What do you have as a result, any errors?
    – x3mxray
    Jun 27 '19 at 15:52
  • It does not work, I updated my question with error thrown
    – sairfan
    Jun 27 '19 at 17:19
  • Do you have a call stack for the exception? It might give important clues as to whether it's thrown before, inside, or after your File() call, and what code is responsible. Jun 28 '19 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.