0

I have this controller method:

public ActionResult GetPDF(string paramYear)
{
   list = new List<Exam>
   {
     new Exam(){Year= "2016"},
     new Exam(){Year= "2017"},
     new Exam(){Year= "2018"}
   };
  return View(list.Where(a => a.Year == paramYear));
}

That return the following view GetPDF view:

<body >
    <object  data="~/Content/Exams/2016/T205_16.pdf" type="text/html" style="float:left;width:100%;height:100%;"></object>   
</body>

I need the following: when the GetPDF method invoked I want that this part will replaced with the correct path data="~/Content/Exams/2016/T205_16.pdf"

For example, If GetPDF was invoked with "2018" the the path inside html will replaced to: data="~/Content/Exams/2016/exam_2018.pdf"

How can I achive that? I tried to get the url paremer like here but it didn't worked well

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Devy
  • 703
  • 6
  • 17

1 Answers1

1

You should pass the parameter from the controller to the view using a view model class.

For more details, see the documentation.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964