EDN Admin
Well-known member
When I open an IE browser and navigate to a Yahoo website, by default I am logged in. However, when I use WebRequest to navigate to the website, it always asks me to log in first, even though I am setting my Credentials. Is there a way to
navigate to the website using WebRequest and already be logged in? Ive tried it per below, and I end up on the login page for Yahoo.
Async Function DoNav(ByVal url As String) As Task(Of Boolean)<br/>
Dim brStr As String<br/>
Dim theRequest As WebRequest<br/>
Dim theResponse As WebResponse<br/>
Dim sr As StreamReader
theRequest = WebRequest.Create(url)<br/>
theRequest.Credentials = CredentialCache.DefaultNetworkCredentials either way doesnt work<br/>
theRequest.Credentials = New NetworkCredential("ewhite2142", "biged3111")<br/>
Dim getStringTask As Task(Of WebResponse) = theRequest.GetResponseAsync<br/>
theResponse = Await getStringTask<br/>
sr = New StreamReader(theResponse.GetResponseStream)<br/>
brStr = sr.ReadToEnd<br/>
sr.Close()<br/>
theResponse.Close()
this is so that I can see the results<br/>
Dim Br As New InternetExplorer<br/>
Br.Visible = True<br/>
Br.Navigate2("about:blank")<br/>
Br.Document.write(brStr) : Br.Document.close()<br/>
Return True<br/>
End Function DoNav
View the full article
navigate to the website using WebRequest and already be logged in? Ive tried it per below, and I end up on the login page for Yahoo.
Async Function DoNav(ByVal url As String) As Task(Of Boolean)<br/>
Dim brStr As String<br/>
Dim theRequest As WebRequest<br/>
Dim theResponse As WebResponse<br/>
Dim sr As StreamReader
theRequest = WebRequest.Create(url)<br/>
theRequest.Credentials = CredentialCache.DefaultNetworkCredentials either way doesnt work<br/>
theRequest.Credentials = New NetworkCredential("ewhite2142", "biged3111")<br/>
Dim getStringTask As Task(Of WebResponse) = theRequest.GetResponseAsync<br/>
theResponse = Await getStringTask<br/>
sr = New StreamReader(theResponse.GetResponseStream)<br/>
brStr = sr.ReadToEnd<br/>
sr.Close()<br/>
theResponse.Close()
this is so that I can see the results<br/>
Dim Br As New InternetExplorer<br/>
Br.Visible = True<br/>
Br.Navigate2("about:blank")<br/>
Br.Document.write(brStr) : Br.Document.close()<br/>
Return True<br/>
End Function DoNav
View the full article