public ActionResult OpenDocument(int documentID)
{
Document doc = Model.DocumentServiceHelper.GetSingleDocument(documentID);
if (doc != null)
{
return File(doc.Data, MimeMapping.GetMimeMapping(doc.Name) , doc.Name);
}
return Json("No File", JsonRequestBehavior.AllowGet);
}
JS:
$('#btnOpenDocument').click(function () {
var documentID = $('#hidDocumentID').val();
window.location.href = '/Documents/OpenDocument?documentID=' + documentID;
});
Html:
<input type="hidden" id="hidDocumentID"
name="DocumentID" value="ViewData["DocumentId"]" />
I tried many documents on stackoverflow.Whatever i tried file return (downloads) without "xls,doc etc.." and i can not open document because of path.
How can i correct this for return file or another solution
Thanks.