简体   繁体   中英

Is it possible to use <iframe> to point to an .aspx page?

I'm trying to use an <iframe> to point to an .aspx file, but when I load it I keep getting an empty frame , no matter what is in the target .aspx nothing gets displayed. Here the html:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        This is the principal page</div>
        <iframe id="myIframe" src="SimpleTarget.aspx" height="100%" width="100%"></iframe> 
    </form>
</body>
</html>

Then I tried it pointing to an html and it was succesfully rendered in the browser showing the html content. Here the html:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        This is the principal page</div>
        <iframe id="myIframe" src="HTMLPage1.htm" height="100%" width="100%"></iframe> 
    </form>
</body>
</html>

So my question is, am I missing something when defining the iframe or is completely impossible to point to an .aspx with an iframe ?

In case it is impossible, is there another way to show aspx pages within another html page?

它应该与SimpleTarget.aspx一起使用,只需确保相对路径正确,并且当您使用浏览器点击页面时页面已加载...

Is this bit a typo? if not it could be your problem

src="SimpleTarget.aspx"height="100%"

should be

src="SimpleTarget.aspx" height="100%"

This is also a typo (but would not break your rendering.

<iframe id="myIframe" src="HTMLPage1.htm" 100%" width="100%">

should be

<iframe id="myIframe" src="HTMLPage1.htm" height="100%" width="100%">

A request for an .aspx page is no different from a request for an HTML file. Either your asp page is not rendering properly (possibly a server error?) or else your iframe is not pointing to it correctly.

I do notice that you have a badly formatted src tag for the .aspx page..

src="SimpleTarget.aspx"height="100%"

should be

src="SimpleTarget.aspx" height="100%"

I found that the following in a Global.asax file stopped iframes opening aspx pages:

void Application_BeginRequest(object sender, EventArgs e) {
    HttpContext.Current.Response.AddHeader("X-Frame-Options", "DENY");
}

Used to stop cross site scripting but also breaks internal iframes when using aspx pages; removing this "fixed" the problem for me.

在Firefox中,您可以右键单击iframe并获取iframe菜单并选择在新选项卡中打开框架 - 这将确认浏览器用于iframe的实际URL以及其他人已声明的允许您确保aspx页面确实正确呈现。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM