Hello, all experts:
May I ask you some questions? First, i'm programming a software of
auto-authentication by using VB.NET tool. This software's functions is
similar to do the account login through browser. I meet some questions when
I post data to authentication page. I have tested the authentication
webpages of Gemtek G-6000 and Cipherium bonalinx-W 1300 separately.
Authentication succeeds for Gemtek, unsuccessful for Cipherium. I think that
the reasons should be cookie's problem. I can get the cookie value browsing
the auth-page of Gemtek, but Cipherium's not. Its headers resopnse message
is as follows:
Date: Tue, 06 Jan 1970 00:54:00 GMT
Server: Apache/1.3.29 (Unix) PHP/4.3.2 mod_ssl/2.8.16 OpenSSL/0.9.7c
X-Powered-By: PHP/4.3.2
Location: error_user.shtml?uname=chen&msg=Can not read data from
Cookie,Please check your browser.
Transfer-Encoding: chunked
Content-Type: text/html
I am unable to fetch the cookie value, so unable to post authentication data
to Cipherium gateway. I don't know why this is? Why one is right but another
is not right? Who can help me to check my code and tell me this where is the
Crux??
List my code as following:
----------------------------------------------------------------------------------------------------
objWebRequest = CType(WebRequest.Create(dURL), HttpWebRequest)
objWebRequest.CookieContainer = New System.Net.CookieContainer
objWebRequest.AllowAutoRedirect = False
objWebRequest.Method = "POST"
objWebRequest.ContentType = "application/x-www-form-urlencoded"
'----------------------------------
' Cookie
'----------------------------------
objWebRequest.ContentLength = postData.Length
objWebRequest.AllowWriteStreamBuffering = False
Dim myWriter As StreamWriter = New
StreamWriter(objWebRequest.GetRequestStream())
myWriter.Write(postData)
myWriter.Close()
'---------------
' Send the Data
'---------------
objWebResponse = CType(objWebRequest.GetResponse(),
HttpWebResponse)
Console.WriteLine(ControlChars.Cr + "{0}",
objWebRequest.RequestUri)
objWebResponse.Cookies =
objWebRequest.CookieContainer.GetCookies(objWebReq uest.RequestUri)
Dim cook As System.Net.Cookie
For Each cook In objWebResponse.Cookies
Console.WriteLine("Cookie:")
Console.WriteLine("{0} = {1}", cook.Name, cook.Value)
Console.WriteLine("Domain: {0}", cook.Domain)
Console.WriteLine("Path: {0}", cook.Path)
Console.WriteLine("Port: {0}", cook.Port)
Console.WriteLine("Secure: {0}", cook.Secure)
Console.WriteLine("When issued: {0}", cook.TimeStamp)
Console.WriteLine("Expires: {0} (expired? {1})",
cook.Expires, cook.Expired)
Console.WriteLine("Don't save: {0}", cook.Discard)
Console.WriteLine("Comment: {0}", cook.Comment)
Console.WriteLine("Uri for comments: {0}", cook.CommentUri)
Console.WriteLine("Version: RFC {0}", IIf(cook.Version = 1,
"2109", "2965"))
Console.WriteLine("String: {0}", cook.ToString())
Next cook
Console.WriteLine(ControlChars.Cr + "{0}",
objWebResponse.Headers.ToString)
---------------------------------------------------------------------------------------------------------------
thanks and regards,
~Kevin