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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.