Search code examples
asp.net-mvc-4iframeurl-action

How to use Url.Action in iframe src


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


Solution

  • 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>