Hi,
I'm trying the following:
- Imitate a Logon using a Post with HttpWebRequest on remote Webserver (asp
3.0 page using https)
- On success redirect to the page (encapsuled in an iframe) supplied by the
remote Webserver
I can successfuly logon but when I redirect to the supplied url, the
webserver does not know me anymore an redirects me back to login page.. I
was told that I need to store the session cookie supplied by the remote
webserver on my webserver, but I don't know how to pass the session cookie
to my my webserver..
Sample Code follows:
Dim urlRed As String = https://book.bla.at/AM/booking/asp/login.asp
Dim wReq As HttpWebRequest = CType(WebReques t.Create(urlRed ),
HttpWebRequest)
wReq.ContentTyp e = "applicatio n/x-www-form-urlencoded"
wReq.Method = "POST"
Dim sPostData As String = "" & Session.Session ID
sPostData = sPostData & "&USERNAME= " & HttpUtility.Url Encode("myuser" )
sPostData = sPostData & "&password= " & HttpUtility.Url Encode("mypassw ord")
sPostData = sPostData & "&language= " & HttpUtility.Url Encode("DE_AT")
Dim enc As System.Text.Enc oding = System.Text.Enc oding.UTF8
Dim bPostBuffer As Byte() = enc.GetBytes(sP ostData)
wReq.ContentLen gth = bPostBuffer.Len gth
Dim streamPostData As Stream = wReq.GetRequest Stream()
streamPostData. Write(bPostBuff er, 0, bPostBuffer.Len gth)
streamPostData. Close()
Dim wResp As HttpWebResponse = CType(wReq.GetR esponse(), HttpWebResponse )
Dim responseStream As StreamReader = New
StreamReader(wR esp.GetResponse Stream(), enc)
' Here I get the correct url to the welcome page encapsuled in html
Dim html As String = responseStream. ReadToEnd()wRes p.Close()
responseStream. Close()
Response.Write( html)
Thanks and Regards
Karsten
I'm trying the following:
- Imitate a Logon using a Post with HttpWebRequest on remote Webserver (asp
3.0 page using https)
- On success redirect to the page (encapsuled in an iframe) supplied by the
remote Webserver
I can successfuly logon but when I redirect to the supplied url, the
webserver does not know me anymore an redirects me back to login page.. I
was told that I need to store the session cookie supplied by the remote
webserver on my webserver, but I don't know how to pass the session cookie
to my my webserver..
Sample Code follows:
Dim urlRed As String = https://book.bla.at/AM/booking/asp/login.asp
Dim wReq As HttpWebRequest = CType(WebReques t.Create(urlRed ),
HttpWebRequest)
wReq.ContentTyp e = "applicatio n/x-www-form-urlencoded"
wReq.Method = "POST"
Dim sPostData As String = "" & Session.Session ID
sPostData = sPostData & "&USERNAME= " & HttpUtility.Url Encode("myuser" )
sPostData = sPostData & "&password= " & HttpUtility.Url Encode("mypassw ord")
sPostData = sPostData & "&language= " & HttpUtility.Url Encode("DE_AT")
Dim enc As System.Text.Enc oding = System.Text.Enc oding.UTF8
Dim bPostBuffer As Byte() = enc.GetBytes(sP ostData)
wReq.ContentLen gth = bPostBuffer.Len gth
Dim streamPostData As Stream = wReq.GetRequest Stream()
streamPostData. Write(bPostBuff er, 0, bPostBuffer.Len gth)
streamPostData. Close()
Dim wResp As HttpWebResponse = CType(wReq.GetR esponse(), HttpWebResponse )
Dim responseStream As StreamReader = New
StreamReader(wR esp.GetResponse Stream(), enc)
' Here I get the correct url to the welcome page encapsuled in html
Dim html As String = responseStream. ReadToEnd()wRes p.Close()
responseStream. Close()
Response.Write( html)
Thanks and Regards
Karsten
Comment