Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 4 如何将复杂模型传递给ActionAsPDF?_Asp.net Mvc 4_Rotativa - Fatal编程技术网

Asp.net mvc 4 如何将复杂模型传递给ActionAsPDF?

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

我正在创建一个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 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) };