Click here to Skip to main content
15,887,917 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
(MVC 5) Why do I use when running the back RazorPDF.PdfResult results are RazorPDF.PdfResult which is not the result of a pdf file

C#
public ActionResult Fprint(int id = 0)
       {

           Person p = new Person();
           p.name = "aaa";
           var pdfresult = new RazorPDF.PdfResult(p);
           pdfresult.ViewBag.Title = "fff";
           return pdfresult;

       }

Fprint.cshtml

C#
@model Example.Models.Person
@Html.LabelFor(x=>x.name)


Results after running:
RazorPDF.PdfResult.
Please help me.Thanks
Posted
Updated 11-Nov-14 17:19pm
v3
Comments
Jameel VM 12-Nov-14 1:06am    
what is the problem?your question is not clear.

1 solution

The problem is if your view is expecting the model of type person(@model Example.Models.Person) you should return the same model from the action result to the view like below
C#
public ActionResult Fprint(int id = 0)
       {
 
           Person p = new Person();
           p.name = "aaa";
           var pdfresult = new RazorPDF.PdfResult(p);
           pdfresult.ViewBag.Title = "fff";
           return view(p);
 
       }


ViewBag data you can access in the view like below
C#
@model Example.Models.Person
@Html.LabelFor(x=>x.name)
<p>@ViewBag.Title<p>

Hope this helps
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900