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. Retain CSS format reading a Page

Retain CSS format reading a Page

Scheduled Pinned Locked Moved ASP.NET
cssquestion
4 Posts 2 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.
  • V Offline
    V Offline
    VickyC
    wrote on last edited by
    #1

    I have the following routine: public static string readHtmlPage(string url) { string result; WebRequest request = WebRequest.Create(url); HttpWebResponse response =(HttpWebResponse) request.GetResponse(); Stream dataStream = response.GetResponseStream(); using (StreamReader reader = new StreamReader(dataStream)) { result = reader.ReadToEnd(); reader.Close(); } return result; } I email the "result" as the body of an email message but it is loosing its CSS formating. It seems that CSS is never applied can anybody detect something wrong?

    G 1 Reply Last reply
    0
    • V VickyC

      I have the following routine: public static string readHtmlPage(string url) { string result; WebRequest request = WebRequest.Create(url); HttpWebResponse response =(HttpWebResponse) request.GetResponse(); Stream dataStream = response.GetResponseStream(); using (StreamReader reader = new StreamReader(dataStream)) { result = reader.ReadToEnd(); reader.Close(); } return result; } I email the "result" as the body of an email message but it is loosing its CSS formating. It seems that CSS is never applied can anybody detect something wrong?

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The path to the css is probably relative. As what you have sent in the mail is no longer a page, and has no url, the mail program don't know from where it should load the css. If you specify a complete url for the css file, it has a possibility to work.

      --- b { font-weight: normal; }

      V 1 Reply Last reply
      0
      • G Guffa

        The path to the css is probably relative. As what you have sent in the mail is no longer a page, and has no url, the mail program don't know from where it should load the css. If you specify a complete url for the css file, it has a possibility to work.

        --- b { font-weight: normal; }

        V Offline
        V Offline
        VickyC
        wrote on last edited by
        #3

        Hm. All of the above is true. So what would return back the complete page?

        G 1 Reply Last reply
        0
        • V VickyC

          Hm. All of the above is true. So what would return back the complete page?

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Either change the page, or change the contents once you have read the page. If you have other resources, like images, their addresses have to be changed also. Some resources won't work even if you supply a correct address, like javascript includes. There is no way that you can keep all functionality when you send the code of a page as a mail. A mail program is not a browser, so it will not support everything that a browser does.

          --- b { font-weight: normal; }

          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