8

How to use the Url.Action method in the iframe src attribute. Like

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

But its not working properly. Its saying that the requested content is not available.

Please help me

2 Answers 2

13

Using ASP.NET engine

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

Using razor engine.

<iframe src = '@Url.Action("HelloWorld", "myController")' width = "100%" 
    height="1000" frameBorder="0"></iframe>
Sign up to request clarification or add additional context in comments.

Comments

-1
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");
        }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.