【问题标题】:How to use Url.Action in iframe src如何在 iframe src 中使用 Url.Action
【发布时间】:2013-07-16 11:25:36
【问题描述】:

如何在iframesrc属性中使用Url.Action方法。喜欢

<iframe src = '<%=Url.Action("HelloWorld", "myController");%>' width = "100%" height="1000" frameBorder="0"></iframe>

但它不能正常工作。它说请求的内容不可用。

请帮帮我

【问题讨论】:

    标签: asp.net-mvc-4 iframe url-action


    【解决方案1】:

    使用 ASP.NET 引擎

    <iframe src = '<%: Url.Action("HelloWorld", "myController") %>' width = "100%" 
        height="1000" frameBorder="0"></iframe>
    

    使用剃须刀引擎。

    <iframe src = '@Url.Action("HelloWorld", "myController")' width = "100%" 
        height="1000" frameBorder="0"></iframe>
    

    【讨论】:

      【解决方案2】:
      Same here found error in getting what type of Controller should be? so this is the best solution if you are using IFrame for PDF Viewer and I hope this code will be useful.
      
      
      <iframe src="@Url.Action("GetPDF")" id="sign" width="800" height="800"></iframe>
      
        public FileStreamResult GetPDF()
              {
                  var path = "E:\\FirstTask\\FirstTask\\FolderToSave\\Patient Consent.pdf";
                  FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
                  return File(fs, "application/pdf");
              }
      

      【讨论】:

        猜你喜欢
        • 2012-01-28
        • 2016-06-18
        • 1970-01-01
        • 1970-01-01
        • 2020-09-14
        • 2015-10-06
        • 1970-01-01
        • 1970-01-01
        • 2023-04-08
        相关资源
        最近更新 更多