c# - Return File not returning pdf correctly MVC 5 -
I am currently using a PDF server side PDF library. When this is done I try to return this PDF to the user.
Every time I try to fail to open PDF, or if I run it down as a download, it downloads as a corrupted file. If I type the physical address of the PDF in the browser, it loads properly.
In my Controller:
In this example, nfilePath = ~ / PdfStore / CurRep103323842.pdf This is something stumped on this simple, any advice would be great. Thank you. See part of that load See partial ............. here a form Controller Built-in PDF generates HTML generated from the main view, which has PDF encoding inside Div Update. You are calling You need to replace that location with a button / link instead, which calls on with: Alternatively, you can add a meta refresh tag or jQuery to emphasize the file download. Return file (nfilePath, "application / pdf");
@modelprintShiftHandover. Model ShiftHandOver @ {ViewBag.Title = "ShiftHandOver"; } & Lt; Div id = "updateRegion" & gt; @ {Html.RenderAction ("_ ReportDetails");} & lt; / Div & gt;
@Model PrintShiftHandover Models. Main report: DEFET @ {layout = string Empty; } & Lt; Div id = "PartialView" & gt; @ Use (Html.BeginForm ()) {
} & lt; / Div & gt;
[http.post] Public functioning _ Description of report (Model Main Report Model Model) {var getfile = new CreatePdf (); Var nfilePath = getfile.getfile (model); Return file (nfilePath, "App / PDF"); } Catch (Exception preceded by {ModelState.AddModelError ("", ex.Message); See Return (Model); }}
@ html.RenderAction inside your output Essentially embedding PDF file
@ Html.ActionLink is. Then change the line that says:
@ {Html.RenderAction ("_ ReportDetails")}}
@html Optional ("_ _ _ _ _ _">)
Comments
Post a Comment