0

I am having problem while downloading a file using mvc application. I don't know what the problem is as my code is not throwing any error and i am new to mvc.

My code is as below:

    public FileResult DownloadDocument(JobModel data)
        {

            string filename = data.DocumentDetails[0].DocumentName;
            string filepath = data.DocumentDetails[0].Path;

            byte[] filedata = System.IO.File.ReadAllBytes(Server.MapPath(PathToSaveDocument + filepath));
            string contentType = MimeMapping.GetMimeMapping(Server.MapPath(PathToSaveDocument + filepath));

            var cd = new System.Net.Mime.ContentDisposition
            {
                FileName = filename,
                Inline = true,
            };

            Response.AppendHeader("Content-Disposition", cd.ToString());

            return File(filedata, contentType);
}

Please help and thanks in advance.

Jitender Singh
  • 75
  • 1
  • 11

0 Answers0