http - Make it possible to download .rtf file -
i able make pdf file downloadable when use clicks download link. did this:
sqldatareader reader = command.executereader(); if (!reader.read()) return; response.clear(); string fileextension = reader["fileext"].tostring().trim(); if (reader["documentdata"] != dbnull.value) { switch (fileextension) case "pdf": response.contenttype = "application/pdf"; break; ... case "rtf": response.contenttype = "application/rtf"; break;
i tried same .rtf, when user clicks link browser instead shows image attached below (weird symbols). want promt user save file. user right clicks on link, , says save (somename.rtf), works fine. old generation of people not know this.
tried with
application/rtf application/x-rtf text/richtext
most of examples found use application/rtf
is there else need do, people can download .rtf files? have tried provide relevant code, please let me know if need more information. in advance
i had has experience php me. solution add this:
case "rtf": response.contenttype = "application/octet-stream"; response.headers["content-transfer-encoding"] = "binary"; response.headers["content-disposition"] = "attachment; filename=\"filename.rtf\""; break;
so force browser download file, instead of trying render it. hope save same amount of time used.
Comments
Post a Comment