在 aspx 中包含 html 页面 - Response.WriteFile() 的奇怪结果
Include html page in aspx - Strange outcome with Response.WriteFile()
我需要将同一个 html
页面包含到多个 aspx
页面中。以下是我的 html
页面:
<h1>Database Enciclopedico</h1>
然后我使用 Response.WriteFile
方法将页面包含在我的 aspx
页面中:
<div id="header">
<% Response.WriteFile("Header.html"); %>
</div>
问题是,当包含 html 页面时,它的开头有几个新行和空格(当我用 Google [=31 检查元素时,我可以看到结果=]).
我该如何解决这个问题?
请尝试以下方法:
<%
string path = HttpContext.Current.Server.MapPath("Header.html");
string content = System.IO.File.ReadAllText(path);
Response.Write(content);
%>
像这样使用 HTML iframe:
<iframe id='iframe1' name='iframe1' src='abc.html'>//also add attributes of height and width
</iframe>
我需要将同一个 html
页面包含到多个 aspx
页面中。以下是我的 html
页面:
<h1>Database Enciclopedico</h1>
然后我使用 Response.WriteFile
方法将页面包含在我的 aspx
页面中:
<div id="header">
<% Response.WriteFile("Header.html"); %>
</div>
问题是,当包含 html 页面时,它的开头有几个新行和空格(当我用 Google [=31 检查元素时,我可以看到结果=]).
我该如何解决这个问题?
请尝试以下方法:
<%
string path = HttpContext.Current.Server.MapPath("Header.html");
string content = System.IO.File.ReadAllText(path);
Response.Write(content);
%>
像这样使用 HTML iframe:
<iframe id='iframe1' name='iframe1' src='abc.html'>//also add attributes of height and width
</iframe>