Here is my code.

        unametxt = textBlock1.Text;
        passtxt = textBlock2.Text;

        WebClient webClient = new WebClient();
        webClient.BaseAddress = "";

        webClient.Credentials = new NetworkCredential(unametxt, passtxt);

        webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
        webClient.DownloadStringAsync(new Uri(""));

After connecting, the source code is downloaded and saved to a string variable.

public void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
            data = e.Result;

The source code that is downloaded is the source code of the login page. I want to download the source code of the page after the login page. How can I do it?

Re: Connect to a website with authentication and download source code C#? 80 80
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.