How to use Url.Action in iframe src

How to use Url.Action method in iframe src attribute. how

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

But it does not work properly. His statement that the requested content is not available.

Please help me

+6
source share
2 answers

Using ASP.NET Engine

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

Using a shaving engine.

 <iframe src = '@Url.Action("HelloWorld", "myController")' width = "100%" height="1000" frameBorder="0"></iframe> 
+10
source
 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"); } 
0
source

Source: https://habr.com/ru/post/949558/


All Articles