trend Posted August 22, 2005 Posted August 22, 2005 Hello, I need to communicate with a webpage to authenticate a user via "Basic" authentication. If I do this via telnet servername.com 80 here is how the converstation would go.. me: GET /FooService/basiconly/Service1.asmx HTTP/1.1 Accept: */* Host: localhost:8100 Connection: Keep-Alive The server responds with a challenge: HTTP/1.1 401 Unauthorized WWW-Authenticate: Digest realm="Login_page", nonce="Ny8yLzIwMDIgMzoyNjoyNCBQTQ", opaque="0000000000000000", stale=false, algorithm=MD5, qop="auth" Then I reply GET /FooService/basiconly/Service1.asmx HTTP/1.1 Accept: */* Host: localhost:8100 Authorization: Digest username="test", realm="RassocDigestSample", qop="auth", algorithm="MD5", uri="/FooService/basiconly/Service1.asmx", nonce="Ny8yLzIwMDIgMzoyNjoyNCBQTQ", nc=00000001, cnonce="c51b5139556f939768f770dab8e5277a", opaque="0000000000000000", response="afa30c6445a14e2817a423ca4a143792" So basically I need to know how to custome make the request and recieve the answers. (I am not talking about getting HTML data.. I am talking about talking directly to the webserver before the HTML data comes into play) thanks! Lee Quote
trend Posted August 22, 2005 Author Posted August 22, 2005 Figure it out.. You have to use the: Imports System.Collections.Specialized.NameValueCollection library Quote
Joe Mamma Posted August 22, 2005 Posted August 22, 2005 I am not sure if this will help. But a little over a year ago cyclonebri needed to script interaction with a website to gather metrics. I wrote a testbed for him here that utilized System.Net, specifically the HttpWebRequest and HttpWebResponse classes. Take a look at the class posted in the last response. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted August 22, 2005 Posted August 22, 2005 By the way . . . cyclonebri are you still around? did that work for you? Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
trend Posted August 22, 2005 Author Posted August 22, 2005 Very cool! I did something like: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim client As New WebClient Dim username As String = "myusername" Dim password As String = "mypw" Dim bytes = Encoding.ASCII.GetBytes(username & ":" & password) client.Headers.Add("Authorization", "Basic " & Convert.ToBase64String(bytes)) Dim googlelogin = "https://mail.google.com/mail/feed/atom" Dim feedStream As Stream = client.OpenRead(googlelogin) Dim reader As New StreamReader(feedStream) Dim feedAsXml As String = reader.ReadToEnd feedStream.Close() textbox2.Text = feedAsXml End Sub But the only problem with this is.. I want to open up a new IE window.. so the user can see the results. (If the webpage is downloaded the opened from C:\, the user will not see the pictures or style sheets that were refered too). So basically I would want the user to end up at: https://mail.google.com/mail/feed/atom (as well as logged in via my header.add ) How can I do this? thanks! Lee Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.