Reputation: 553
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?
Upvotes: 2
Views: 41168
Reputation: 1731
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.
Upvotes: 1
Reputation: 1541
In firefox you can right click in th iframe and get an iframe menu and choose to open the frame in a new tab - this will confirm the actual url being used by the browser for the iframe and as others have stated allow you to ensure the aspx page does render correctly.
Upvotes: 0
Reputation: 47447
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%">
Upvotes: 3
Reputation: 116987
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%"
Upvotes: 1
Reputation: 11223
It should work with SimpleTarget.aspx just make sure that the relative path is correct and the page is loaded when you hit it with the browser ...
Upvotes: 4