11.6. Get an HTML Page from a Site That Requires Authentication

Problem

You need to retrieve a file from a web site, but the web site requires that you provide credentials for the purpose of authentication.

Solution

Use the System.Net.WebRequest and System.Net.WebResponse classes as described in recipe 11-4. Before making the request, configure the WebRequest.Credentials and WebRequest.Certificates properties with the necessary authentication information.

You could also use the System.Net.WebClient class (discussed in recipe 11-3). It also has Credentials and Certificates properties that allow you to associate user credentials with a web request. ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.