我有这个控制器方法:
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));
}
返回以下视图 GetPDF 视图:
<body >
<object data="~/Content/Exams/2016/T205_16.pdf" type="text/html" style="float:left;width:100%;height:100%;"></object>
</body>
我需要以下内容:调用GetPDF方法时,我希望此部分将替换为正确的路径data="~/Content/Exams/2016/T205_16.pdf"
例如,如果用“ 2018”调用GetPDF,则html内的路径将替换为:
data="~/Content/Exams/2016/exam_2018.pdf"
我该如何实现?我尝试获取网址解析器like here,但效果不佳