Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Want to display HTML file in aspx page

Want to display HTML file in aspx page

Scheduled Pinned Locked Moved ASP.NET
htmlwpfsysadminhelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anand Desai
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • A Anand Desai

      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

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • C Colin Angus Mackay

        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.

        A Offline
        A Offline
        Anand Desai
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • A Anand Desai

          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

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          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 like www.yourdomain.com/folder/filename.html

          Navaneeth How to use google | Ask smart questions

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups