473,465 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HttpWebRequest: Cookies question

When I run the code below, the web server tells me that I need to
enable cookies. Can anyone tell me what might be causing that? I'm
trying to POST userid and password to their login web page. Thanks!

Dim CookieJar As CookieContainer = New CookieContainer()
Dim WebReq As HttpWebRequest
Dim WebResp As HttpWebResponse
Dim StrmRdr As StreamReader
Dim StrmWrtr As StreamWriter
Dim PostParms As String
Dim URLString As String
Dim HTML as String
= "https://www.nordstrombanking.com/onlineserv/HB/Login.cgi"

WebReq = CType(WebRequest.Create(New Uri(URLString)),
HttpWebRequest)
WebReq.CookieContainer = CookieJar
WebReq.Credentials = CredentialCache.DefaultCredentials
WebReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.1; .NET CLR 1.0.3705)"
WebReq.KeepAlive = True
WebReq.Headers.Set("Pragma", "no-cache")
WebReq.Timeout = 30000
WebReq.Method = "POST"
WebReq.ContentType = "application/x-www-form-urlencoded"
PostParms = "userNumber=12345678&password=87654321&OK=subm it&"
& _
"runmode=SIGN_IN&LAST_ACTIVE_URL="
WebReq.ContentLength = PostParms.Length
StrmWrtr = New StreamWriter(WebReq.GetRequestStream)
StrmWrtr.Write(PostParms)
StrmWrtr.Close()
WebResp = WebReq.GetResponse
StrmRdr = New StreamReader(WebResp.GetResponseStream)
HTML = StrmRdr.ReadToEnd.Trim
StrmRdr.Close()
WebResp.Close()

The source for the web page is:

<meta http-equiv="Pragma" Content="no-cache">
<meta http-equiv="Expires" Content="Tuesday, 14-Dec-1971 04:30:00
GMT">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Internet Banking Timeout</title> <!-- for non-nav pages -->
<!--
<script language="JavaScript">
ldt = new Date;
inSubmit = 0;
function dofocus() {
document.Login.userNumber.focus();
inSubmit = 0;
}
function clear() {
document.Login.userNumber.value = "";
document.Login.password.value = "";
dofocus();
}
function formField1()
{
Ctrl = document.Login.userNumber;
if (Ctrl.value == "")
{
validatePrompt (Ctrl, "Please enter a valid Customer Number.")
return (false);
}
else
return (true);
}
function formField2()
{
bName = navigator.appName; // get version of Navigator
bVer = parseInt(navigator.appVersion);
// if Netscape 2.0 or below just get out
if (bName == "Netscape" && bVer < 3)
return (true);
Ctrl = document.Login.password;
if (Ctrl.value == "")
{
validatePrompt (Ctrl, "Please enter a Password.")
return (false);
}
else
return (true);
}
function runSubmit (form)
{
if (!formField1())
return false;

if (!formField2())
return false;
// Due to the re-direct from the timeout warning, this no longer
works.
// form.LAST_ACTIVE_URL.value = window.location.search;
document.cookie = "signonValid=TRUE; path=/";
return true;
}
function validatePrompt (Ctrl, PromptStr)
{
alert(PromptStr);
Ctrl.focus();
return;
}
// -->
</script>
</head>

<body bgcolor=white leftmargin=3 onload="dofocus()">

<div align="center">
<br><br>
<span class="mainTitle">Internet Banking Timeout</span>

<form autocomplete="OFF" name="Login" method="post"
action="./Login.cgi" onsubmit="return runSubmit(this)">

<table width="500" border="0">
<tr>
<td valign="top">

<span class="subtitle">For security reasons, your Internet Banking
session has timed out. Please login again by entering your customer
number and password here...<BR><BR>If you would like to increase your
session timeout please do so by clicking on the User Options button
inside of Internet Banking.</span>

<br><br>
</td>
<td valign="top" width="15"><br></td>
<td valign="top">
<table border="1">
<tr>
<td align="center">
<span class="sectionTitle">Customer Number</span><br>
<input type="hidden" name="runmode" value="SIGN_IN">
<input type="hidden" name="LAST_ACTIVE_URL" value="">&nbsp;
<input name="userNumber" size="16" maxlength="32"> &nbsp;
</td>
</tr>
<tr>
<td align=center>
<span class="sectionTitle">Password</span><br>&nbsp;
<input type="password" name="password" size="16" maxlength="8">
&nbsp;
</td>
</tr>
<tr>
<td align="center" valign="middle">
<input name="OK" type="submit" value=" Enter ">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>

</div>

<!-- end of IB Timeout -->

</body>
</html>
Jul 21 '05 #1
3 4087
Jerry Rhodes wrote:
When I run the code below, the web server tells me that I need to
enable cookies. Can anyone tell me what might be causing that? I'm
trying to POST userid and password to their login web page. Thanks!

Dim CookieJar As CookieContainer = New CookieContainer()
Dim WebReq As HttpWebRequest
Dim WebResp As HttpWebResponse
Dim StrmRdr As StreamReader
Dim StrmWrtr As StreamWriter
Dim PostParms As String
Dim URLString As String
Dim HTML as String
= "https://www.nordstrombanking.com/onlineserv/HB/Login.cgi"

WebReq = CType(WebRequest.Create(New Uri(URLString)),
HttpWebRequest)
WebReq.CookieContainer = CookieJar
WebReq.Credentials = CredentialCache.DefaultCredentials
WebReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.1; .NET CLR 1.0.3705)"
WebReq.KeepAlive = True
WebReq.Headers.Set("Pragma", "no-cache")
WebReq.Timeout = 30000
WebReq.Method = "POST"
WebReq.ContentType = "application/x-www-form-urlencoded"
PostParms = "userNumber=12345678&password=87654321&OK=subm it&"
& _
"runmode=SIGN_IN&LAST_ACTIVE_URL="
WebReq.ContentLength = PostParms.Length
StrmWrtr = New StreamWriter(WebReq.GetRequestStream)
StrmWrtr.Write(PostParms)
StrmWrtr.Close()
WebResp = WebReq.GetResponse
StrmRdr = New StreamReader(WebResp.GetResponseStream)
HTML = StrmRdr.ReadToEnd.Trim
StrmRdr.Close()
WebResp.Close()

The source for the web page is: [...] function runSubmit (form)
{
if (!formField1())
return false;

if (!formField2())
return false;
// Due to the re-direct from the timeout warning, this no longer
works.
// form.LAST_ACTIVE_URL.value = window.location.search;
document.cookie = "signonValid=TRUE; path=/"; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

return true;
}


Ah, the josys of remote controlling some third-party web app ;-)

You didn't reverse engineer the web form completely. Your code does not set
this cookie. Adding it to your cookie container should do the trick.

Cheers,

--
Joerg Jooss
jo*********@gmx.net
Jul 21 '05 #2

Joerg,

Thank you very, very much for your response. What would a developer in
the MS world do without Google and people like you??? Your idea got me
past the cookie question. Now the only HTML I'm getting back is below.
"HomeBanking" is the final destination page, but who knows what happened
in the web server. Thanks again!!
<html>
<head>
<meta http-equiv="refresh" content="25;url=html/JavaScriptError.html">
<script language="JavaScript">
<!--
location.href = "HomeBanking.cgi";
// -->
</script>
</head>
<body>
</body>
</html>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3
Jerry Rhodes wrote:
Joerg,

Thank you very, very much for your response. What would a developer
in the MS world do without Google and people like you??? Your idea
got me past the cookie question. Now the only HTML I'm getting back
is below. "HomeBanking" is the final destination page, but who knows
what happened in the web server. Thanks again!!


Jerry,

so HomeBanking.cgi gets you there? Great. Never mind the weird architecture
they're using. When I looked at their home page, I found a number of funny
things nobody in my team would implement if he knew what's good for him ;-)

Cheers,

--
Joerg Jooss
jo*********@gmx.net
Jul 21 '05 #4

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

Similar topics

0
by: TJO | last post by:
Can someone at MS please reply to this. I am trying to post data so a web form via ssl with the following code. I keep getting this error: "The underlying connection was closed: Could not...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
6
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....
4
by: Dan | last post by:
Question about the environment used by HttpWebRequest when making requests: When I use IE to browse a site, all of my cookies, etc. are available as part of the request. However, when I make...
11
by: Keith Patrick | last post by:
Could someone explain to me the relationship between these two classes? I am ripping my hair out trying to divert an HttpRequest to a new location via an HttpWebRequest, but I cannot get my...
16
by: Cheung, Jeffrey Jing-Yen | last post by:
I have a windows form application that generates a request, downloads an image, and waits the user to enter in login info. Unfortunately, this image is dynamic and based on session data. I have...
0
by: Alex Papadimoulis | last post by:
Hey Group, I'm in the process of converting an ASP-based site to an ASP.NET site and built a control that wraps around an ASP page. The control simply does a GET to the same server to render the...
0
by: Alex Papadimoulis | last post by:
Hey Group, I'm in the process of converting an ASP-based site to an ASP.NET site and built a control that wraps around an ASP page. The control simply does a GET to the same server to render the...
6
by: James MA | last post by:
I'm now writing a small program to communicate a web server to simulate a web client. I use te httpwebrequest to talk with the server, and it works find for "POST" method, however, when i test...
5
by: rlueneberg | last post by:
I am totally confused. Can someone please illuminate what is going on under the hood in this piece of code from John Lewis. My main confusion is how the cookieContainer can be passed to the...
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
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,...
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...
1
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.