Trying to extract the contents of an ESPN web page that requires an ESPN Insider username/password (yes, I am a valid member of that service, and yes, this is actually for work). Can I use a NetworkCredential object to pass the username/password? When I run the code below, it downloads the redirected web page that asks for the usr/pwd instead of the "sitelines" page that I'm interested in. Am I going about this the right way?
private sub GetTheFile Const FILENAME As String = "c:\fred.html" Me.Cursor = Cursors.WaitCursor Dim uri As New Uri("http://insider.espn.go.com/insider/sitelines? s=1&sport=mlb&team=all&player=") Dim aCache As New CredentialCache() Dim aCred As New NetworkCredential("usr", "pwd") Call aCache.Add(uri, "Basic", aCred) Dim req As HttpWebRequest = WebRequest.Create(uri) req.Credentials = aCache Dim res As HttpWebResponse = req.GetResponse() Dim sr As New StreamReader(res.GetResponseStream(), Encoding.ASCII) Dim sOut As StreamWriter 'dont worry if not exists Try File.Delete(FILENAME) Catch End Try Try sOut = New StreamWriter(FILENAME) sOut.Write(sr.ReadToEnd) Catch oex As Exception Call MsgBox("ERROR: " & oex.Message) Finally sr.Close() res.Close() sOut.Close() Me.Cursor = Cursors.Default End Try End Sub You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.