473,387 Members | 1,536 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,387 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 3172
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.