如何在MVC3中为iframe的src属性提供html文件的路径

MVC*_*ate 4 iframe asp.net-mvc-3

我在提供IFrame src的路径时遇到问题.

我把我的html文件保存在同一个目录中.但我仍然没有得到它

我写的是这样的:

  <iframe id="iframe" frameborder="0" src="Dancing.htm" style="width: 100%; height: 700px;"></iframe>
Run Code Online (Sandbox Code Playgroud)

但它没有找到资源给我错误但是如果我写一个视图(.cshtml)页面而不是HTM页面它正确加载我不是不知道为什么会发生这种情况

请帮我.

Yor*_*rgo 5

您必须在Views文件夹中找到*.html文件.

创建HTML文件夹并将Dancing.htm文件复制到该文件夹

/HTML/Dancing.htm
Run Code Online (Sandbox Code Playgroud)
<iframe id="iframe" frameborder="0" src="@Url.Content("~/HTML/Dancing.htm")" style="width: 100%; height: 700px;"></iframe>
Run Code Online (Sandbox Code Playgroud)