.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to Get the HTML for Given URL IN C#?

Posted By:Lakhan Pal Garg       Posted Date: June 28, 2010    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

Sample Code to get the HTML for the given URL.

public string ReadUrl()
        Uri uri = new Uri("http://lakhangarg.blogspot.com");
        //Create the request object

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
        req.UserAgent = "Get Content";
        WebResponse resp = req.GetResponse();
        Stream stream = resp.GetResponseStream();
        StreamReader sr = new StreamReader(stream);
        string s = sr.ReadToEnd();
        string strurl = "-1";
        s = s.Replace("\"", "'");
        while (s.IndexOf("
-1) { s = s.Substring(s.IndexOf("


Thanks & Regards

Lakhan Pal Garg


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend