Want to display HTML file in aspx page
-
Hi coders, I want to display one HTML file contents in my aspx page. I am using for that. what I have written is: aspx page: <iframe frameborder="no" id="htmlAboutUs" style="width:100%; height:500px;" runat="server" scrolling="no"> cs file:
htmlAboutUs.Attributes["src"] = Server.MapPath(FolderName + "/styles/About-Us.html");
where FolderName is comming from session. Its not working but. its showing blank page in result(not even "Page Not Found"). Then I tried another one: FileStream fs = new FileStream(Server.MapPath(FolderName + "/styles/About-Us.html"), FileMode.Open); byte[] data = new byte[fs.Length]; fs.Read(data, 0, (int)fs.Length); fs.Close(); string dataString = Encoding.UTF8.GetString(data); htmlAboutUs.InnerText = dataString; It is also not working. I have checked that its bringing correct data in dataString but not displaying. mean my file contents are properly read but its not assigned to iframe. Please give some gidence. Thanks for any help.
Anand Desai Developer Atharva Infotech
-
Hi coders, I want to display one HTML file contents in my aspx page. I am using for that. what I have written is: aspx page: <iframe frameborder="no" id="htmlAboutUs" style="width:100%; height:500px;" runat="server" scrolling="no"> cs file:
htmlAboutUs.Attributes["src"] = Server.MapPath(FolderName + "/styles/About-Us.html");
where FolderName is comming from session. Its not working but. its showing blank page in result(not even "Page Not Found"). Then I tried another one: FileStream fs = new FileStream(Server.MapPath(FolderName + "/styles/About-Us.html"), FileMode.Open); byte[] data = new byte[fs.Length]; fs.Read(data, 0, (int)fs.Length); fs.Close(); string dataString = Encoding.UTF8.GetString(data); htmlAboutUs.InnerText = dataString; It is also not working. I have checked that its bringing correct data in dataString but not displaying. mean my file contents are properly read but its not assigned to iframe. Please give some gidence. Thanks for any help.
Anand Desai Developer Atharva Infotech
Anand Desai wrote:
Its not working but
That is because you are using MapPath to return the Physical path as seen internally on the server. The browser does not have access to that. You must use a URL (http://domain/folder/styles/About-Us.html)
* Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
-
Anand Desai wrote:
Its not working but
That is because you are using MapPath to return the Physical path as seen internally on the server. The browser does not have access to that. You must use a URL (http://domain/folder/styles/About-Us.html)
* Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
Colin Angus Mackay wrote:
MapPath to return the Physical path as seen internally on the server.
I am using localhost anyways. and i think, on web server also, MapPath should work properly. Thanks.
Anand Desai Developer Atharva Infotech
-
Colin Angus Mackay wrote:
MapPath to return the Physical path as seen internally on the server.
I am using localhost anyways. and i think, on web server also, MapPath should work properly. Thanks.
Anand Desai Developer Atharva Infotech
Anand Desai wrote:
and i think, on web server also, MapPath should work properly.
No.
MapPath
will give the physical path to the file. That physical path is not accessible from browser. So you need to render path likewww.yourdomain.com/folder/filename.html
Navaneeth How to use google | Ask smart questions