假设我在 MVC3 控制器中有以下三个操作方法:
public ActionResult ShowReport()
{
return View("ShowReport");
}
[PageOptions(OutputFormat = OutputFormat.Web)]
public ActionResult ShowReportForWeb()
{
return View("ShowReport");
}
[PageOptions(OutputFormat = OutputFormat.Pdf)]
public ActionResult ShowReportForPdf()
{
return View("ShowReport");
}
在我的 Razor 视图中,我希望能够告诉您:
- PageOptions 属性是否附加到调用操作方法。
- 如果是,它的 OutputFormat 属性的值是多少。
这是一些伪代码,说明了我正在尝试做的事情:
@if (pageOptions != null && pageOptions.OutputFormat == OutputFormat.Pdf)
{
@:This info should only appear in a PDF.
}
这可能吗?