Asp.net mvc 4 如何将复杂模型传递给ActionAsPDF?
我正在创建一个MVC4应用程序。我正在使用Rotativa生成PDF 他们有一个叫做Asp.net mvc 4 如何将复杂模型传递给ActionAsPDF?,asp.net-mvc-4,rotativa,Asp.net Mvc 4,Rotativa,我正在创建一个MVC4应用程序。我正在使用Rotativa生成PDF 他们有一个叫做 public ActionAsPdf(string action, object routeValues); 我无法将复杂对象传递到RouteValue i、 e: 我有一个模型 public class FullName { public string FirstName { get; set; } public string Surname { get; set; } } public
public ActionAsPdf(string action, object routeValues);
我无法将复杂对象传递到RouteValue
i、 e:
我有一个模型
public class FullName
{
public string FirstName { get; set; }
public string Surname { get; set; }
}
public ActionResult Index(FullName name)
{
ViewBag.Message = string.Format("Hello {0} to ASP.NET MVC!", name);
return View();
}
public ActionResult Test()
{
var fullname = new FullName();
fullname.FirstName = "John";
fullname.Surname = "Smith";
return new ActionAsPdf("Index", new { name = fullname }) { FileName = "Test.pdf" };
}
当我单步执行时,在索引
操作中,名称为空。。。如何传递复杂模型?检查此项
return new ActionAsPdf("Index", fullname ) { FileName = "Test.pdf" };
那就简单地说吧
return new ActionAsPdf("viewForPDFFile", new { id = id} ) { FileName = String.Format("File_{0}.pdf",id) };
如何将两个viewmodels传递给ActionAsPdf?
return new ActionAsPdf("viewForPDFFile", new { id = id} ) { FileName = String.Format("File_{0}.pdf",id) };