0
이 expoert되지 않으면 안되는 액션 : PDF에 대한 Rotativa 패키지 을 1 비주얼 스튜디오 2015 MVC (5) 설치를MVC (5)가 수출 만있어 PDF로 내보낼 로그인 페이지
[Authorize(Roles = "admin,operator")]
public ActionResult Index()
{
return View(db.Students.ToList());
}
최대 동작은 책임이있다
@model IEnumerable<ProjectOne.Models.Student>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.StatusName)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
</tr>
}
</table>
@Html.ActionLink("Export", "ExportIndex") //this will run ExportIndex
이 I : 약간의 값을 선택하고 뷰에 표시하는 도면
이 될 수있는 부분이다보기 s를 ExportIndex :
[Authorize(Roles = "admin,operator")]
public ActionResult ExportIndex(int ? id)
{
return new ActionAsPdf("Index") { FileName = "Test.pdf" };
}
이제 내보내기 문제는 내가 [에 권한 부여를 변경하는 경우 여기,이 PDF 있지만 로그인 화면의 PDF를 생성합니다 심지어 내가 같은 역할의 사용자로 로그인하고 잘못되어하지 않는 것입니다 후 AllowAnonymous ] 작동하지만 권한이 필요합니다. 이것은 역할이 적용될 경우 pdf로 내보낼 페이지입니다.
intializer
ActionAsPdf
개체에서 쿠키를 포함해야합니다. "ActionAsPdf"대신 "ViewAsPdf"를 사용해 볼 수 있습니까? – Nirman@Nirman 사전에 전달 된 모델 항목의 형식은 '<> f__AnonymousType3'1 [System.Nullable'1 [System.Int32]]'이지만이 사전에는 'System.Collections.Generic.IEnumerable'형식의 모델 항목이 필요합니다 '1 –