HTTPS SSL redirection problem -
05-05-2009
, 05:22 AM
Using HttpWebRequest to send login information via an HTTPS SSL
channel from my desktop works just fine (.Net 3.5).
Moving the code to the Compact Framework (.Net CF 3.5) works when
incorrect login info are sent to the web server. When I send correct
ones, the GetResponse method throws a WebException.
The message (translated by me from Italian) is: "To satisfy the
request it is necessary to insert authentication data into the buffer
or to do a redirection."
The original message is: "Per soddisfare la richiesta è necessario
inserire nel buffer i dati di autenticazione o eseguire un
reindirizzamento."
<code>
Public Function SendRequest(ByVal URL As String, ByVal Content As
String) As String
'Note that Content = "action=xxxxx&login=xxxxx&op=login&pwd=xxxxx"
Dim request = DirectCast(WebRequest.Create(URL),
HttpWebRequest)
cookieManager.PublishCookies(request) 'Just adds cookies to
the request
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
Dim postdata = Encoding.ASCII.GetBytes(Content)
request.ContentLength = postdata.Length
Dim st = request.GetRequestStream
st.Write(postdata, 0, postdata.Length)
st.Close()
Dim response = DirectCast(request.GetResponse,
HttpWebResponse) '<<<- this works on .Net 3.5 but on CF
Dim sr = New StreamReader(response.GetResponseStream)
Dim responseBody = sr.ReadToEnd
sr.Close()
</code>
Thx to who answer!
Sid. |