Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can acquire the HTML source in C# using the following code:

using System;
using System.Net;

class Program
{
    static void Main(string[] args)
    {
        using (WebClient client = new WebClient())
        {
            string htmlSource = client.DownloadString("https://www.example.com");
            Console.WriteLine(htmlSource);
        }
    }
}

This code downloads the HTML source of the given URL using the WebClient class and stores it in the htmlSource variable. You can then print or process the HTML source as needed.