473,408 Members | 1,741 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,408 software developers and data experts.

webrequest POST to HTTPS

Hi

Sorry to be posting slabs of code, but i simply can't get this code to
work. I continue to get error 405, method not allowed at
req.GetRequestStream(). Can't for the life of me figure out why, i
mean, of course POSTing is allowed, that's how the site submits the
user data!

WebRequest req =
WebRequest.Create("https://www2.netbank.commbank.com.au/netbank/NetBank/scripts/cgiclnt.dll/CORE-Main%20Web/ND000_");

byte [] data = null;
data =
System.Text.Encoding.ASCII.GetBytes("EWF_SYS_0=611 18042-ff0a-11d0-98df-006097b70359&EWF_FORM_NAME=aBegin&BANK%20ID=CBA&PR ODUCT%20NAME=EBS&GROUP=BANKING&LANGUAGE%20ID&USERI D=myID&PIN=myPIN&EWFBUTTON&EXTRA3=bankmain&LOGONID =myID&LOGONPIN=myPIN&SUBMIT%20BUTTON=Logon");

req.Method="post";
req.ContentType="application/x-www-form-urlencoded";
req.ContentLength = data.Length;

Stream outputStream = req.GetRequestStream();

outputStream.Write (data, 0, data.Length);

outputStream.Close();

//retrieveFromURL
WebResponse response = req.GetResponse();

Stream responseStream = response.GetResponseStream();

StreamReader reader = new StreamReader(responseStream);
string htmlContent = reader.ReadToEnd();

cheers
Dave

Nov 16 '05 #1
5 21006
ok here's some more info: I got the entire bank logon page, copied it
to my own server, filled it out, submitted it, and it gave me exactly
the same error! what on earth is it doing? that is, how did it know
that the submit page was bona fide?

cheers
dave

Nov 16 '05 #2
ma**********@hotmail.com wrote:
Hi

Sorry to be posting slabs of code, but i simply can't get this code to
work. I continue to get error 405, method not allowed at
req.GetRequestStream(). Can't for the life of me figure out why, i
mean, of course POSTing is allowed, that's how the site submits the
user data!

WebRequest req =
WebRequest.Create("https://www2.netbank.commbank.com.au/netbank/NetBank/scripts/cgiclnt.dll/CORE-Main%20Web/ND000_");

byte [] data = null;
data =
System.Text.Encoding.ASCII.GetBytes("EWF_SYS_0=611 18042-ff0a-11d0-98df-006097b70359&EWF_FORM_NAME=aBegin&BANK%20ID=CBA&PR ODUCT%20NAME=EBS&GROUP=BANKING&LANGUAGE%20ID&USERI D=myID&PIN=myPIN&EWFBUTTON&EXTRA3=bankmain&LOGONID =myID&LOGONPIN=myPIN&SUBMIT%20BUTTON=Logon");

req.Method="post";
req.ContentType="application/x-www-form-urlencoded";
req.ContentLength = data.Length;

Stream outputStream = req.GetRequestStream();

outputStream.Write (data, 0, data.Length);

outputStream.Close();

//retrieveFromURL
WebResponse response = req.GetResponse();

Stream responseStream = response.GetResponseStream();

StreamReader reader = new StreamReader(responseStream);
string htmlContent = reader.ReadToEnd();


You're not processing any cookies. You should use a CookieContainer with
your WebRequests. The site uses cookies.

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de
Nov 16 '05 #3
I've tried this:

WebRequest req =
(HttpWebRequest)WebRequest.Create("https://www2.netbank.commbank.com.au/netbank/NetBank/scripts/cgiclnt.dll/CORE-Main%20Web/ND000_");
req.Method="post";
req.Headers.Set("Referer","https://www2.netbank.commbank.com.au/netbank/bankmain.htm");

but it errors me: "Headers must be modified with appropriate property."
Any ideas?

cheers
dave

Nov 16 '05 #4

You should probably use:

req.Referer = "https://www2.netbank.commbank.com.au/netbank/bankmain.htm"

instead of explicitly setting the header. I'm guessing that you possibly end
up with two referers in the header which is giving you that error.

In addition it looks like you're POSTing, but you're nto actually sending
data which could be another problem.

BTW, where is that error coming from? THe message you're describing seems
like a server side application message - which could arise from a number of
things dealing with how the form is supposed to be submitted.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
----------------------------------
Making waves on the Web
<ma**********@hotmail.com> wrote in message
news:10*********************@f14g2000cwb.googlegro ups.com...
I've tried this:

WebRequest req =
(HttpWebRequest)WebRequest.Create("https://www2.netbank.commbank.com.au/netb
ank/NetBank/scripts/cgiclnt.dll/CORE-Main%20Web/ND000_"); req.Method="post";
req.Headers.Set("Referer","https://www2.netbank.commbank.com.au/netbank/bank
main.htm");
but it errors me: "Headers must be modified with appropriate property."
Any ideas?

cheers
dave

Nov 16 '05 #5
Well i'm getting closer. The code was supposed to be:

HttpWebRequest req
=(HttpWebRequest)WebRequest.Create("https://www2.netbank.commbank.com.au/netbank/NetBank/scripts/cgiclnt.dll/CORE-Main%20Web/ND000_");

rather than just WebRequest=etc

still getting the problem though, even after fixing the referer to something
reasonable. seems like this is not going to be as easy as i hoped.

cheers
dave
Nov 16 '05 #6

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

Similar topics

3
by: Frank Schwarz | last post by:
Hello, we are implemting an application that uses a https connection for accessing a website. It is also possible to connect via http. With http every thing works fine. With https it is not...
2
by: Christian Pické | last post by:
Hi, I have to do a POST to an URI. I already figured out this code: WebRequest myRequest = WebRequest.Create("https://select.worldpay.com/wcc/purchase"); myRequest.Method = "POST";
2
by: Tony Guidici | last post by:
I have been attempting to send an XML post to a ASPX page I created as a listener. On our Windows Server 2003 Web Edition server, I installed a test certificate from Thawte and can hit the page...
2
by: oliver.wulff | last post by:
Hi My ASP.NET application has to send https requests to other web servers quite often. I'd like to know how I should manage the connections? Does the method WebRequest.Create() reuses an existing...
1
by: Nelson R. | last post by:
Hi, i need to get some info from a website page that requires an certificate. Ive got the provided certificate installed in IE, and when accessing the website page, it shows a window to...
3
by: Bob Powell [MVP] | last post by:
It's not often I ask questions but here goes... I am writing a site that does Instant Payment Notification processing through PayPal and I need to use HttpWebRequest to hit an HTTPS server at...
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...
3
by: leeo | last post by:
Hi We've upgraded to VB.NET from VB6, but are now having some difficulty in understanding how to communicate data to the DPB website (the dental practice board). Could anyone help in...
3
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. I'm trying to create a call to a web page to validate and register software. The code I'm using is: Private Sub OK_Click(ByVal sender As...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
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
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
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...
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...

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.