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.

enter image description here 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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -