not sure why your URL is coded for GET call while your are obviously trying
to do a POST call.
The receiving end may be confused by that.
Also, since this an HTTPS session, and the server is probably load balanced,
you will need to get the Login page, collect the cookies, and send them back
on the POST request and all subsequent requests. This is nearly always a
requirement, because load balancers can provide the SSL decoding most
efficiently when they can piggyback a session variable to determine which
system is connected once SSL is stripped off.
Hope this helps,
--- Nick
> I'm trying to login to a banking site
> (https://www.providentconnection.com) using vb.net. I've tried many
[quoted text clipped - 11 lines]
>
> url = "https://www.providentconnection.com/Login.asp?Login=plugh&Password=xyzzy&Va
lidationReq=1&WhichBrowser=IE&pgBrowserVersion=4"
> myWebClient.Headers.Add("Content-Type",
> "application/x-www-form-urlencoded")
[quoted text clipped - 80 lines]
>
> Gill
Gill Bates - 31 Jul 2004 02:46 GMT
Indeed; it helped enormously!
I now have a working prototype; it was the Cookie that did the trick
I had played around with the code until it was pretty screwed up in
the GET/POST ing; that's now taken care of.
For any other poor souls; here's the working code
(needs polish)
Thanks so much!!
Dim cookieJar As CookieContainer = New CookieContainer
Dim webReq As HttpWebRequest
Dim webResp As HttpWebResponse
Dim sr As StreamReader
Dim sw As StreamWriter
Dim payLoad As String
Dim txt As String
webReq = CType(WebRequest.Create(New Uri(urlString)),
HttpWebRequest)
webReq.CookieContainer = cookieJar
webReq.Credentials = CredentialCache.DefaultCredentials
webReq.UserAgent = "BGClient"
webReq.KeepAlive = True
webReq.Headers.Set("Pragma", "no-cache")
webReq.Timeout = 5000
webReq.Method = "GET"
' get login page
webResp = webReq.GetResponse
sr = New StreamReader(webResp.GetResponseStream)
txt = sr.ReadToEnd.Trim
sr.Close()
webResp.Close()
webReq = CType(WebRequest.Create(New Uri(urlString & uriString)),
HttpWebRequest)
webReq.CookieContainer = cookieJar
webReq.Credentials = CredentialCache.DefaultCredentials
webReq.UserAgent = "BGClient"
webReq.KeepAlive = True
webReq.Headers.Set("Pragma", "no-cache")
webReq.Timeout = 5000
webReq.Method = "POST"
webReq.ContentType = "application/x-www-form-urlencoded"
payLoad = "Login=gill&Password=bates&submit=Login&ValidationReq=1&WhichBrowser=Microsoft+Internet+Explorer&pgBrowserVersion=4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CLR+1.1.4322;+.NET+CLR+1.0.3705)"
webReq.ContentLength = payLoad.Length
sw = New StreamWriter(webReq.GetRequestStream)
sw.Write(payLoad)
sw.Close()
' post login parms
webResp = webReq.GetResponse
sr = New StreamReader(webResp.GetResponseStream)
txt = sr.ReadToEnd.Trim
sr.Close()
webResp.Close()
> not sure why your URL is coded for GET call while your are obviously trying
> to do a POST call.
[quoted text clipped - 18 lines]
> >
> etc....