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. HTML Source From URL

HTML Source From URL

Scheduled Pinned Locked Moved ASP.NET
csharphtmlcom
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.
  • R Offline
    R Offline
    raju melveetilpurayil
    wrote on last edited by
    #1

    code for get HTML Source from input URL using System.Web.Caching; using System.Net; using System.IO; string URL = TextBox1.Text;//INPUT URL if (URL.Substring(0, 7) != "http://")//CHECK URL CONTAIN http:// { URL = "http://"+TextBox1.Text; } string ConvertURL =(string)Cache.Get(URL); if (ConvertURL == null) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(URL)); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); StreamReader srdr = new StreamReader(res.GetResponseStream()); ConvertURL = srdr.ReadToEnd(); } Response.Write(ConvertURL);

    Raju.M http://aspdotnetprogrammer.blogspot.com/

    G 1 Reply Last reply
    0
    • R raju melveetilpurayil

      code for get HTML Source from input URL using System.Web.Caching; using System.Net; using System.IO; string URL = TextBox1.Text;//INPUT URL if (URL.Substring(0, 7) != "http://")//CHECK URL CONTAIN http:// { URL = "http://"+TextBox1.Text; } string ConvertURL =(string)Cache.Get(URL); if (ConvertURL == null) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(URL)); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); StreamReader srdr = new StreamReader(res.GetResponseStream()); ConvertURL = srdr.ReadToEnd(); } Response.Write(ConvertURL);

      Raju.M http://aspdotnetprogrammer.blogspot.com/

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

      makhaai wrote:

      URL = "http://"+TextBox1.Text;

      Why reading it from the text box again? Just do: URL = "http://" + URL;

      makhaai wrote:

      string ConvertURL =(string)Cache.Get(URL);

      Why do you look in the cache for the source? Do you have any code elsewhere that stores anything in the cache? You forgot to dispose the HttpWebResponse and the StreamReader.

      --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

      N 1 Reply Last reply
      0
      • G Guffa

        makhaai wrote:

        URL = "http://"+TextBox1.Text;

        Why reading it from the text box again? Just do: URL = "http://" + URL;

        makhaai wrote:

        string ConvertURL =(string)Cache.Get(URL);

        Why do you look in the cache for the source? Do you have any code elsewhere that stores anything in the cache? You forgot to dispose the HttpWebResponse and the StreamReader.

        --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

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

        He was not asking a question, it seems like he is advertising this[^]

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

        G 1 Reply Last reply
        0
        • N N a v a n e e t h

          He was not asking a question, it seems like he is advertising this[^]

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

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

          N a v a n e e t h wrote:

          He was not asking a question

          Yeah, I didn't see any question, but he got an answer anyway. :)

          N a v a n e e t h wrote:

          it seems like he is advertising this[^]

          Seems you can take any crappy code and make a blog out of it... ;)

          --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

          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