473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

HELP: Implementing cookies with WebRequest and WebResponse

Here's my problem...

When I use this code to hit the site in question I'm redirected to another
SSL login page. If processed successfully the page creates a cookie and
then redirects you to the original request.

However, my code cannot seem to hold onto the cookie it creates. Does
anyone know how to do this?
Everything works (SSL included) *except* for the cookies. trying to figure
that one out still.

Here is the code:
Imports System
Imports System.IO
Imports System.Net
Imports System.Threading
Imports System.Text.RegularExpressions
Imports System.Text.Encoding
Imports System.Security.Cryptography.X509Certificates

Public Class TrustAllCertificatePolicy
Implements System.Net.ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As
System.Net.ServicePoint, ByVal certificate As
System.Security.Cryptography.X509Certificates.X509 Certificate, ByVal request
As System.Net.WebRequest, ByVal certificateProblem As Integer) _
As Boolean Implements
System.Net.ICertificatePolicy.CheckValidationResul t
Return True
End Function
End Class
Private Sub cmdGet_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdGet.Click
'Create(a) 'WebRequest' object with the specified url
System.Net.ServicePointManager.CertificatePolicy = New
TrustAllCertificatePolicy

Dim myWebRequest As WebRequest
'myWebRequest.Credentials = myCert.TrustAllCertificatePolicy
myWebRequest =
WebRequest.Create("https://sentri.us.nortel.com:8443/SENTRI/home.jsp")

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse
myWebResponse = myWebRequest.GetResponse()
' Call method 'GetResponseStream' to obtain stream associated with
the response object
Dim ReceiveStream As Stream
ReceiveStream = myWebResponse.GetResponseStream()

Dim encode As System.Text.Encoding
encode = GetEncoding("utf-8")

' Pipe the stream to a higher level stream reader with the required
encoding format.
Dim readStream As New StreamReader(ReceiveStream, encode)
'txtLog.Text = (ControlChars.CrLf + "Response stream received")
Dim read(1024) As [Char]

' Read 256 charcters at a time .
Dim count As Integer = readStream.Read(read, 0, 1024)
txtLog.Text = ""
'While count > 0
While readStream.Peek >= 0

' Dump the 256 characters on a string and display the string
onto the console.
Dim str As New [String](read, 0, count)
txtLog.Text = txtLog.Text & (str)
count = readStream.Read(read, 0, 1024)

End While
Dim str2 As New [String](read, 0, count)
txtLog.Text = txtLog.Text & (str2)
count = readStream.Read(read, 0, 1024)
'Console.WriteLine("")

' Release the resources of stream object.
readStream.Close()

' Release the resources of response object.
myWebResponse.Close()

End Sub

Nov 20 '05 #1
0 1171

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: No_Excuses | last post by:
All, I am interested in reading the text of a web page and parsing it. After searching on this newgroup I decided to use the following: ******************************* START OF CODE...
9
by: Justin Engelman | last post by:
Hi, I have a website that uses an ISAPI filter that will redirect anyone going to any page on the site to an SSL login page (on a different website with the same root domain) if they do not have...
0
by: Tony Archer | last post by:
Here's my problem... When I use this code to hit the site in question I'm redirected to another SSL login page. If processed successfully the page creates a cookie and then redirects you to the...
0
by: Gordon | last post by:
I use the following code to get source HTML. The second line seems to work when I get no response from a site. However, I want to stop the request if it's taking more than 20 - 30 seconds. I can't...
2
by: Mr Flibble | last post by:
Hey! I get a 404 from a website (this is "correct behaviour") and I'm interested in the value in the cookie "SMSESSION". The question is the following code generates an exception due to the...
0
by: Naga | last post by:
I am using the code below to login to a password requiring website programatically. I keep getting back the logon page. I have read some posts here and haven't found a working solution still. I...
2
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an...
1
by: Mr Flibble | last post by:
OK I logon to a web site and I manage to get an SMSESSION cookie that I then store in a variable called _session (a class scoping variable). I do this by calling a logon URL and setting a cookie...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
0
by: nomad | last post by:
Hi, I am using HTTPWebRequest to add a client certificate. I am then using HTTPWebRequest to POST xml to a web service which requires the attached client certificate to authenticate with their...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.