我有一个视图,我想使用 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 的一部分加载。我想要一个标签并在它下面显示以下内容:localhost/Pdf /PdfAs内容
我试过:
@{
    ViewBag.Title = "Index";
}
<h2>Index</h2>
<div>
    @Url.Action("PdfAsContent")
</div>
但它返回:Index pdf/PdfAsContent