472,992 Members | 3,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

POST data to form not working

I'm developping a program to automate the submisson of grades to a
website called omnivox.ca (http://brebeuf.omnivox.ca). My problem is
that I can't get the login working. I get the cookie right and the post
data is corect. But when I sniff the http packet it contains not post
data and he response is not the same. Here are the sniffed post
packets.

POST from IE6
(Request-Line):POST
/Estd/Default.aspx?C=BRE&E=P&L=FRA&Ref=20051122161245 HTTP/1.1
Accept:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*
Referer:https://brebeuf.omnivox.ca/Estd/Default.aspx?
Accept-Language:en-ca
Content-Type:application/x-www-form-urlencoded
Accept-Encoding:gzip, deflate
User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET
CLR 2.0.50727; .NET CLR 1.1.4322)
Host:brebeuf.omnivox.ca
Content-Length:44
Connection:Keep-Alive
Cache-Control:no-cache
Cookie:comn=BRE; lngomn=FRA
RESPONSE
(Status-Line):HTTP/1.1 302 Found
Date:Tue, 22 Nov 2005 21:28:02 GMT
Server:Microsoft-IIS/6.0
X-Powered-By:ASP.NET
X-AspNet-Version:1.1.4322
Location:https://brebeuf.omnivox.ca/estd/Veri...20051122162802
Set-Cookie:comn=BRE; expires=Wed, 22-Nov-2006 21:28:02 GMT; path=/
Set-Cookie:lngomn=FRA; expires=Wed, 22-Nov-2006 21:28:02 GMT; path=/
Cache-Control:private
Content-Type:text/html; charset=iso-8859-1
Content-Length:254

POST from csharp
(Request-Line):POST
/Estd/Default.aspx?C=BRE&E=P&L=FRA&Ref=20051122161245 HTTP/1.1
Content-Type:application/x-www-form-urlencoded
User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET
CLR 2.0.50727; .NET CLR 1.1.4322)
Host:brebeuf.omnivox.ca
Cookie:comn=BRE; lngomn=FRA
Content-Length:44
Expect:100-continue
RESPONSE
(Status-Line):HTTP/1.1 100 Continue

Here is my code:

string uri = "http://brebeuf.omnivox.ca/";
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create(uri);
myHttpWebRequest.CookieContainer = new CookieContainer();
HttpWebResponse myHttpWebResponse =
(HttpWebResponse)myHttpWebRequest.GetResponse();
myHttpWebResponse.Close();
string postData =
"formEtudiant=o&NoDA=000000&NIP=PASS&x=0&y=0";
byte[] byte1 = Encoding.UTF8.GetBytes(postData);
HttpWebRequest myHttpWebRequest2 =
(HttpWebRequest)WebRequest.Create(myHttpWebRespons e.ResponseUri);
myHttpWebRequest2.ContentType =
"application/x-www-form-urlencoded";
myHttpWebRequest2.ContentLength = postData.Length;
myHttpWebRequest2.Method = "POST";
myHttpWebRequest2.CookieContainer =
myHttpWebRequest.CookieContainer;
myHttpWebRequest2.AllowAutoRedirect = true;
Stream newStream = myHttpWebRequest2.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);
newStream.Close();

I really don't get why it isn't working, please help me out I need to
finish this soon. If any other informations is need ask for it. Thank
you in advance.

Nov 24 '05 #1
1 3139
lo*****@gmail.com wrote:
I'm developping a program to automate the submisson of grades to a
website called omnivox.ca (http://brebeuf.omnivox.ca). My problem is
that I can't get the login working. I get the cookie right and the
post data is corect. But when I sniff the http packet it contains not
post data and he response is not the same. Here are the sniffed post
packets.

POST from IE6
(Request-Line):POST
/Estd/Default.aspx?C=BRE&E=P&L=FRA&Ref=20051122161245 HTTP/1.1
Accept:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*
Referer:https://brebeuf.omnivox.ca/Estd/Default.aspx?
Accept-Language:en-ca
Content-Type:application/x-www-form-urlencoded
Accept-Encoding:gzip, deflate
User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
.NET CLR 2.0.50727; .NET CLR 1.1.4322)
Host:brebeuf.omnivox.ca
Content-Length:44
Connection:Keep-Alive
Cache-Control:no-cache
Cookie:comn=BRE; lngomn=FRA
RESPONSE
(Status-Line):HTTP/1.1 302 Found
Date:Tue, 22 Nov 2005 21:28:02 GMT
Server:Microsoft-IIS/6.0
X-Powered-By:ASP.NET
X-AspNet-Version:1.1.4322
Location:https://brebeuf.omnivox.ca/estd/Veri...n1=WBuuh3CLOA%
3d%3d&n2=WRyugA%3d%3d&C=BRE&E=P&L=FRA&Ref=20051122 162802
Set-Cookie:comn=BRE; expires=Wed, 22-Nov-2006 21:28:02 GMT; path=/
Set-Cookie:lngomn=FRA; expires=Wed, 22-Nov-2006 21:28:02 GMT; path=/
Cache-Control:private Content-Type:text/html; charset=iso-8859-1
Content-Length:254

POST from csharp
(Request-Line):POST
/Estd/Default.aspx?C=BRE&E=P&L=FRA&Ref=20051122161245 HTTP/1.1
Content-Type:application/x-www-form-urlencoded
User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
.NET CLR 2.0.50727; .NET CLR 1.1.4322)
Host:brebeuf.omnivox.ca
Cookie:comn=BRE; lngomn=FRA
Content-Length:44
Expect:100-continue
RESPONSE
(Status-Line):HTTP/1.1 100 Continue
Your HTTP capture shouldn't end here. The question is: Does it end here?
Here is my code:

string uri = "http://brebeuf.omnivox.ca/";
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create(uri);
myHttpWebRequest.CookieContainer = new CookieContainer();
HttpWebResponse myHttpWebResponse =
(HttpWebResponse)myHttpWebRequest.GetResponse();
myHttpWebResponse.Close();
string postData =
"formEtudiant=o&NoDA=000000&NIP=PASS&x=0&y=0";
byte[] byte1 = Encoding.UTF8.GetBytes(postData);
HttpWebRequest myHttpWebRequest2 =
(HttpWebRequest)WebRequest.Create(myHttpWebRespons e.ResponseUri);
myHttpWebRequest2.ContentType =
"application/x-www-form-urlencoded";
myHttpWebRequest2.ContentLength = postData.Length;
myHttpWebRequest2.Method = "POST";
myHttpWebRequest2.CookieContainer =
myHttpWebRequest.CookieContainer;
myHttpWebRequest2.AllowAutoRedirect = true;
Stream newStream = myHttpWebRequest2.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);
newStream.Close();


Why do fetch a page before logging in? That shouldn't be necessary.

--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 25 '05 #2

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

Similar topics

5
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the...
3
by: TG | last post by:
I have a form that POSTs to itself and validates data entered into the form. If all is well the form performs a header location command to move to the next input form in the series. If the user has...
4
by: Pavils Jurjans | last post by:
Hallo, I am working on multilingual web-application, and I have to be very sure about how the international characters are encoded and decoded in the client-server form requests. There's a...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button...
15
by: tmax | last post by:
PHP Pros: I have a simple html form that submits data to a php script, which processes it, and then redisplays the same page, but with a "thank you" message in place of the html form. This is...
8
by: Laith Zraikat | last post by:
I am trying to invoke a post request from code behind of an asp.net page using "WebClient" object, and I want the user to be redirected to the action url as well. So far Ive been able to send...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
4
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.