我有一个View,我想使用Controller.Example中另一个方法的返回值:
public class PdfController : Controller
{
//
// GET: /Pdf/
public ActionResult Index()
{
return View();
}
public FileResult PdfAsContent()
{
return File(@"C:\Users\...\english.pdf","application/pdf");
}
}
当我导航到 localhost / Pdf / PdfAsContent 时,它成功加载了PDF的内容,但我想将其作为View的一部分加载。我希望有一个lable并在其下面显示: localhost / Pdf / PdfAsContent
显示的内容我尝试过:
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<div>
@Url.Action("PdfAsContent")
</div>
但它返回: 指数 PDF / PdfAsContent
答案 0 :(得分:0)
您甚至可以使用Google Docs Viewer。您需要在网址中设置embedded=true
。
例如,如果您想在网址http://research.google.com/archive/bigtable-osdi06.pdf上查看PDF,则可以使用以下网址:http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.google.com%2Farchive%2Fbigtable-osdi06.pdf