473,842 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing and displaying SSL web pages and cookies from a windows form

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 the appropriate session cookie
already. After logging in on that page successfully they are given the
cookie and redirected back to the page they initially tried to go to.

I would like to create a Windows application that gets data from that
website and utilizes that SSL login form and the session cookie generated by
it. Then as the user is using the application it will make calls to the
website to get needed information, which will cause the ISAPI filter to see
that the user has that cookie.

I don't have control over the user logins or passwords or the ISAPI filter
code or SSL login page.

My question is, is it possible to display the login webpage from my
application when the application is first loaded, then to capture the cookie
after the user logs in and the data generated by the page they are
redirected back to after login. If it is, how would I go about doing that?
Also, how would my application "remember" the user's cookie so that
subsequent calls to my website to get data can authenticate the user from
the data in the cookie and also not redirect to the login page.

Thank you for any help you can give me,
Justin
Nov 20 '05 #1
9 1963
Cor
Hi Justin,

A more ASPNET question I have seldom seen.
(If you have the logical solution, than maybe we can help you with VB.net).

I think you can ask this question better in this newsgroup.

Aspnet
<news://msnews.microsof t.com/microsoft.publi c.dotnet.framew ork.aspnet>

Web interface:

<http://communities2.microsoft.com/co...s/?dg=microsof
t.public.dotnet .framework.aspn et>
I hope this helps a little bit?

Cor

"Justin Engelman" <Gl******@adelp hia.net> schreef in bericht
news:Mu******** ************@ad elphia.com...
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 the appropriate session cookie
already. After logging in on that page successfully they are given the
cookie and redirected back to the page they initially tried to go to.

I would like to create a Windows application that gets data from that
website and utilizes that SSL login form and the session cookie generated by it. Then as the user is using the application it will make calls to the
website to get needed information, which will cause the ISAPI filter to see that the user has that cookie.

I don't have control over the user logins or passwords or the ISAPI filter
code or SSL login page.

My question is, is it possible to display the login webpage from my
application when the application is first loaded, then to capture the cookie after the user logs in and the data generated by the page they are
redirected back to after login. If it is, how would I go about doing that? Also, how would my application "remember" the user's cookie so that
subsequent calls to my website to get data can authenticate the user from
the data in the cookie and also not redirect to the login page.

Thank you for any help you can give me,
Justin

Nov 20 '05 #2
Hmmm, ok, perhaps I didn't explain it well enough...
I am actually creating a client/server application. The server is a
webserver running IIS and is set up already, my question is about creating
the Windows Form client (compiled to an exe) that will run on users'
machines. It needs to be able to talk to the webserver through http calls
or LoadXML calls to urls on the website in order to get data or post data to
the server. Normally I would do this through XMLDocument.Loa dXML calls,
passing the url of the page I want to load (since I can set my pages up to
return XML). My problem is that any call to any page on that web site is
first redirected to a SSL login page, if a particular cookie is not present,
by an ISAPI filter installed in IIS for that site. So if I try to
programmaticall y get data from the website to load into a listbox control on
my Windows form the call will get redirected to the login page because the
cookie is not present instead of getting the data.

So I think what I need is the Windows Application upon load to essentially
look/act just like Internet Explorer by being able to navigate to the
website SSL login page and display that page to the user just as it would be
displayed in Internet Explorer and once the user logs in to capture and be
able to persist the cookie that the login page creates for future
programmatic calls to that website.

I also need to be able to tell in my Windows application that the user
successfully logged in by reading the cookie that is generated or the page
that the login page redirects back to.

example of my problem:
if I try making a call like
myXmlDom.LoadXM L("http://whateversite.co m/someData.xml"), instead of loading
someData.xml, it will get redirected to the login page and try to load that
into myXmlDom and fail because that is not properly formatted XML (and even
if it were, it would not be the data I wanted).

Am I making sense? Does this still sound like something that should be
posted in the ASP.NET group instead of here?

Thank You,
Justin
"Cor" <no*@non.com> wrote in message
news:uU******** **********@TK2M SFTNGP12.phx.gb l...
Hi Justin,

A more ASPNET question I have seldom seen.
(If you have the logical solution, than maybe we can help you with VB.net).
I think you can ask this question better in this newsgroup.

Aspnet
<news://msnews.microsof t.com/microsoft.publi c.dotnet.framew ork.aspnet>

Web interface:

<http://communities2.microsoft.com/co...s/?dg=microsof t.public.dotnet .framework.aspn et>
I hope this helps a little bit?

Cor

"Justin Engelman" <Gl******@adelp hia.net> schreef in bericht
news:Mu******** ************@ad elphia.com...
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 the appropriate session cookie
already. After logging in on that page successfully they are given the
cookie and redirected back to the page they initially tried to go to.

I would like to create a Windows application that gets data from that
website and utilizes that SSL login form and the session cookie generated
by
it. Then as the user is using the application it will make calls to the
website to get needed information, which will cause the ISAPI filter to

see
that the user has that cookie.

I don't have control over the user logins or passwords or the ISAPI

filter code or SSL login page.

My question is, is it possible to display the login webpage from my
application when the application is first loaded, then to capture the

cookie
after the user logs in and the data generated by the page they are
redirected back to after login. If it is, how would I go about doing

that?
Also, how would my application "remember" the user's cookie so that
subsequent calls to my website to get data can authenticate the user from the data in the cookie and also not redirect to the login page.

Thank you for any help you can give me,
Justin


Nov 20 '05 #3
Cor
Ok Justin,

More clear but now you have to find a lot yourself, I only can give you the
tools I think you can have a look for.

The axwebbrowser to get your page and to get information from that.
microsoft webbrowser you have to set a reference for that

Getting informatation from that
mshtml you have to set a reference for that
(and not use an import because it has to many interfaces and it freezes your
IDE)

For the cookies
Httprequest

But how to do it, I would not know and I think that your question is very
special.

Cor
Nov 20 '05 #4
Actually, Justin. I understand EXACTLY what you're talking about. Why?
Because I'm trying to do the EXACT same thing.

Below is a bit of code I'm using to pull the page (however the cookies are
still a problem...looki ng for a solution still)

Imports SystemImports System.IO

Imports System.Net

Imports System.Threadin g

Imports System.Text.Reg ularExpressions

Imports System.Text.Enc oding

Imports System.Security .Cryptography.X 509Certificates
Nov 20 '05 #5
Actually, Justin. I understand EXACTLY what you're talking about. Why?
Because I'm trying to do the EXACT same thing.

Below is a bit of code I'm using to pull the page (however the cookies are
still a problem...looki ng for a solution still)

Imports SystemImports System.IO

Imports System.Net

Imports System.Threadin g

Imports System.Text.Reg ularExpressions

Imports System.Text.Enc oding

Imports System.Security .Cryptography.X 509Certificates
Nov 20 '05 #6
Ooops, accidentally submitted a half - post... anyhow. Trying to do the
EXACT same thing here, Justin.

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.Threadin g
Imports System.Text.Reg ularExpressions
Imports System.Text.Enc oding
Imports System.Security .Cryptography.X 509Certificates

Public Class TrustAllCertifi catePolicy
Implements System.Net.ICer tificatePolicy
Public Function CheckValidation Result(ByVal srvPoint As
System.Net.Serv icePoint, ByVal certificate As
System.Security .Cryptography.X 509Certificates .X509Certificat e, ByVal request
As System.Net.WebR equest, ByVal certificateProb lem As Integer) _
As Boolean Implements
System.Net.ICer tificatePolicy. CheckValidation Result
Return True
End Function
End Class
Private Sub cmdGet_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles cmdGet.Click
'Create(a) 'WebRequest' object with the specified url
System.Net.Serv icePointManager .CertificatePol icy = New
TrustAllCertifi catePolicy

Dim myWebRequest As WebRequest
'myWebRequest.C redentials = myCert.TrustAll CertificatePoli cy
myWebRequest =
WebRequest.Crea te("https://sentri.us.norte l.com:8443/SENTRI/home.jsp")

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse
myWebResponse = myWebRequest.Ge tResponse()
' Call method 'GetResponseStr eam' to obtain stream associated with
the response object
Dim ReceiveStream As Stream
ReceiveStream = myWebResponse.G etResponseStrea m()

Dim encode As System.Text.Enc oding
encode = GetEncoding("ut f-8")

' Pipe the stream to a higher level stream reader with the required
encoding format.
Dim readStream As New StreamReader(Re ceiveStream, encode)
'txtLog.Text = (ControlChars.C rLf + "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.WriteL ine("")

' Release the resources of stream object.
readStream.Clos e()

' Release the resources of response object.
myWebResponse.C lose()

End Sub
Nov 20 '05 #7
Ooops, accidentally submitted a half - post... anyhow. Trying to do the
EXACT same thing here, Justin.

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.Threadin g
Imports System.Text.Reg ularExpressions
Imports System.Text.Enc oding
Imports System.Security .Cryptography.X 509Certificates

Public Class TrustAllCertifi catePolicy
Implements System.Net.ICer tificatePolicy
Public Function CheckValidation Result(ByVal srvPoint As
System.Net.Serv icePoint, ByVal certificate As
System.Security .Cryptography.X 509Certificates .X509Certificat e, ByVal request
As System.Net.WebR equest, ByVal certificateProb lem As Integer) _
As Boolean Implements
System.Net.ICer tificatePolicy. CheckValidation Result
Return True
End Function
End Class
Private Sub cmdGet_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles cmdGet.Click
'Create(a) 'WebRequest' object with the specified url
System.Net.Serv icePointManager .CertificatePol icy = New
TrustAllCertifi catePolicy

Dim myWebRequest As WebRequest
'myWebRequest.C redentials = myCert.TrustAll CertificatePoli cy
myWebRequest =
WebRequest.Crea te("https://sentri.us.norte l.com:8443/SENTRI/home.jsp")

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse
myWebResponse = myWebRequest.Ge tResponse()
' Call method 'GetResponseStr eam' to obtain stream associated with
the response object
Dim ReceiveStream As Stream
ReceiveStream = myWebResponse.G etResponseStrea m()

Dim encode As System.Text.Enc oding
encode = GetEncoding("ut f-8")

' Pipe the stream to a higher level stream reader with the required
encoding format.
Dim readStream As New StreamReader(Re ceiveStream, encode)
'txtLog.Text = (ControlChars.C rLf + "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.WriteL ine("")

' Release the resources of stream object.
readStream.Clos e()

' Release the resources of response object.
myWebResponse.C lose()

End Sub
Nov 20 '05 #8
Actually, Justin. I understand EXACTLY what you're talking about. Why?
Because I'm trying to do the EXACT same thing.

Below is a bit of code I'm using to pull the page (however the cookies are
still a problem...looki ng for a solution still)

Imports SystemImports System.IO

Imports System.Net

Imports System.Threadin g

Imports System.Text.Reg ularExpressions

Imports System.Text.Enc oding

Imports System.Security .Cryptography.X 509Certificates
Nov 20 '05 #9
Ooops, accidentally submitted a half - post... anyhow. Trying to do the
EXACT same thing here, Justin.

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.Threadin g
Imports System.Text.Reg ularExpressions
Imports System.Text.Enc oding
Imports System.Security .Cryptography.X 509Certificates

Public Class TrustAllCertifi catePolicy
Implements System.Net.ICer tificatePolicy
Public Function CheckValidation Result(ByVal srvPoint As
System.Net.Serv icePoint, ByVal certificate As
System.Security .Cryptography.X 509Certificates .X509Certificat e, ByVal request
As System.Net.WebR equest, ByVal certificateProb lem As Integer) _
As Boolean Implements
System.Net.ICer tificatePolicy. CheckValidation Result
Return True
End Function
End Class
Private Sub cmdGet_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles cmdGet.Click
'Create(a) 'WebRequest' object with the specified url
System.Net.Serv icePointManager .CertificatePol icy = New
TrustAllCertifi catePolicy

Dim myWebRequest As WebRequest
'myWebRequest.C redentials = myCert.TrustAll CertificatePoli cy
myWebRequest =
WebRequest.Crea te("https://sentri.us.norte l.com:8443/SENTRI/home.jsp")

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse
myWebResponse = myWebRequest.Ge tResponse()
' Call method 'GetResponseStr eam' to obtain stream associated with
the response object
Dim ReceiveStream As Stream
ReceiveStream = myWebResponse.G etResponseStrea m()

Dim encode As System.Text.Enc oding
encode = GetEncoding("ut f-8")

' Pipe the stream to a higher level stream reader with the required
encoding format.
Dim readStream As New StreamReader(Re ceiveStream, encode)
'txtLog.Text = (ControlChars.C rLf + "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.WriteL ine("")

' Release the resources of stream object.
readStream.Clos e()

' Release the resources of response object.
myWebResponse.C lose()

End Sub
Nov 20 '05 #10

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

Similar topics

8
3977
by: ndsoumah | last post by:
hello guys I'm trying to get access to variables I put in a session variable from another page and it fails... here's the exact situation main file page1.php
6
3096
by: omyek | last post by:
I'm trying to mimic the browsing of a webpage using an HttpWebRequest. I've had a lot of luck with it so far, including logging into pages, posting form data, and even collecting and using cookies. However, I ran into a scenario that I'm baffled by. I have a website which requires a user to login. This is nothing new and I was able to successfully log in. For our case, let's say the URL to the login page is http://login.html
0
2272
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or updating the code-behind dll) accessing any aspx page in the application causes the application to run for the first time. Some of the initialization involves reading and writing some text and xml files using simple streamreader and streamwriter...
4
1811
by: lalitha1024 | last post by:
Hi, In my Asp.net project when i am login to my site, i'll set th cookies by using below commands. Dim IdCookie As New HttpCookie("empid" ds.Tables(0).Rows(0).Item(0)) Dim FnameCookie As New HttpCookie("empname" ds.Tables(0).Rows(0).Item(1)) Response.Cookies.Add(IdCookie) Response.Cookies.Add(FnameCookie)
3
1354
by: niju | last post by:
Hi there, I have three web pages (A,B,C). I need to prevent users accessing page B and C without accessing A. What would be the best way to achieve this rule? Many Thanks Niju
9
5321
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of copy paste (I hear this will improve in ASP.Net 2 via master pages). When I navigate from one page to the next the header and footer user controls lose their state because they are effectively different instances of the user control. Is there...
6
5811
by: Coleen | last post by:
Hi all :-) I need to redirect to multiple pages on click of a transmit button, without redisplaying each page. This redirection is to capture session variables that are created on each page and pass them to the main page to be displayed. We are actually NOT using session variables, but storing the values in a temporary table. The problem is that the values don't get stored in the temporary table unless the user goes to each page...
5
1951
by: RSH | last post by:
I havent been able to set a property from another class with out getting some sort of error. Can someone please tell me what I'm doing wrong here? Public Class Form1
20
4506
by: Tim Reynolds | last post by:
Team, I am developing a web service. In testing in on my enw PC, I am expecting to see exceptions thrown appear on my browser. Instead I am getting an HTTP 500 Internal Server Error page and I am not seeing my exception details. The web.config file being used has the setting <customErrors mode="Off"/>. This should allow me to see the detailed exception info. On a different computer - same code - same web config - the exception details...
0
9876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9717
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10952
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9459
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7862
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5699
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4506
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3148
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.