c# - returning file after saving it on disk in mvc -
i have problem in returning file after saving on disk !! pleaaase
note:the function "downloadfile" work when call directly .
public actionresult exportreport(ienumerable<student> user_list) { reportdocument rd = new reportdocument(); rd.load(path.combine(server.mappath("~/reports"), "crystalreport2.rpt")); rd.setdatasource(user_list); rd.exporttodisk(exportformattype.portabledocformat, @"d:\reports\file.pdf"); return redirectpermanent("http://localhost:21104/home/downloadfile"); } public actionresult downloadfile() { string filename = "file.pdf"; string filepath = @"d:\reports\" + filename; byte[] filedata = system.io.file.readallbytes(filepath); string contenttype = mimemapping.getmimemapping(filepath); var cd = new system.net.mime.contentdisposition { filename = filename, inline = true, }; response.appendheader("content -disposition", cd.tostring()); return file(filedata, contenttype); }
Comments
Post a Comment