Nick
Nick

Reputation: 10499

Include html page in aspx - Strange outcome with Response.WriteFile()

I need to include the same html page into several aspx pages. Following is my html page:

<h1>Database Enciclopedico</h1>

And I use the Response.WriteFile method to include the page in my aspx page:

<div id="header">
        <% Response.WriteFile("Header.html"); %>
    </div>

The problem is that when the html page is included it has several new lines and white spaces at its beginning (I can see the result when I inspect the element with Google Chrome).

enter image description here

How can I solve this problem?

Upvotes: 1

Views: 1474

Answers (2)

Pratik Gupta
Pratik Gupta

Reputation: 77

use HTML iframe like this:

    <iframe id='iframe1' name='iframe1' src='abc.html'>//also add attributes of height and width

</iframe>

Upvotes: 0

gliderkite
gliderkite

Reputation: 8928

Please try the following approach:

<%
    string path = HttpContext.Current.Server.MapPath("Header.html");
    string content = System.IO.File.ReadAllText(path);
    Response.Write(content);
%>

Upvotes: 1

Related Questions