2017-01-23 16 views

答えて

0

OnResultExecuting中にレスポンスをタップし、Filterプロパティを結果のHTMLをMemoryStreamに格納するものに置き換えることができます。その後、OnResultExecuted中にResponseをクリアし、PDF変換の結果で置き換えることができます。 URLからHTMLを取得するよりも、これがうまくいくかどうかはわかりません。

例えば=

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 

namespace WebApplication2.Models 
{ 
    public class Person 
    { 
     public string Name { get; set; } 
     public string Email { get; set; } 
     public int Age { get; set; } 
    } 
} 



public ActionResult GetPersons() 
     { 
      List<Person> persons = new List<Person>(); 
      persons.Add(new Person() { Age = 29, Name = "Rami1", Email = "[email protected]" }); 
      persons.Add(new Person() { Age = 28, Name = "Rami2", Email = "[email protected]" }); 
      return View(persons); 
     } 

@model IEnumerable<WebApplication2.Models.Person> 

@{ 
    ViewBag.Title = "GetPersons"; 
} 

<h2>GetPersons</h2> 

<table class="table"> 
    <tr> 
     <th> 
      @Html.DisplayNameFor(model => model.Name) 
     </th> 
     <th> 
      @Html.DisplayNameFor(model => model.Email) 
     </th> 
     <th> 
      @Html.DisplayNameFor(model => model.Age) 
     </th> 
     <th></th> 
    </tr> 

@foreach (var item in Model) { 
    <tr> 
     <td> 
      @Html.DisplayFor(modelItem => item.Name) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Email) 
     </td> 
     <td> 
      @Html.DisplayFor(modelItem => item.Age) 
     </td> 
    </tr> 
} 

</table> 
関連する問題