public ActionResult OpenDocument(int documentID)
{
    Document doc = Model.DocumentServiceHelper.GetSingleDocument(documentID);

    if (doc != null)
    {

      string destinationPath = "." + doc.FileExtension;


      return File(doc.Data, MimeMapping.GetMimeMapping(doc.Name), doc.Name + Path.GetFileName(destinationPath));

    }
   return Json("No File", JsonRequestBehavior.AllowGet);
}

doc.FileExtension is "xls" or "pdf". I add "." with doc.FileExtension.

string destinationPath Result is MyFileName.xls or MyFileName.pdf

However

when i return file doc.Name + Path.GetFileName(destinationPath) displays below

"MyFileName.xls--" or "MyFileName.pdf-" on downloaded file name

How can i correct "-" problem (syntax problem) according to my code ?

Thanks.

Related posts

Recent Viewed