473,775 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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&R ef=200511221612 45 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:applicatio n/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.om nivox.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:Microsof t-IIS/6.0
X-Powered-By:ASP.NET
X-AspNet-Version:1.1.432 2
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=F RA; 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&R ef=200511221612 45 HTTP/1.1
Content-Type:applicatio n/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.om nivox.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 myHttpWebReques t =
(HttpWebRequest )WebRequest.Cre ate(uri);
myHttpWebReques t.CookieContain er = new CookieContainer ();
HttpWebResponse myHttpWebRespon se =
(HttpWebRespons e)myHttpWebRequ est.GetResponse ();
myHttpWebRespon se.Close();
string postData =
"formEtudiant=o &NoDA=000000&NI P=PASS&x=0&y=0" ;
byte[] byte1 = Encoding.UTF8.G etBytes(postDat a);
HttpWebRequest myHttpWebReques t2 =
(HttpWebRequest )WebRequest.Cre ate(myHttpWebRe sponse.Response Uri);
myHttpWebReques t2.ContentType =
"applicatio n/x-www-form-urlencoded";
myHttpWebReques t2.ContentLengt h = postData.Length ;
myHttpWebReques t2.Method = "POST";
myHttpWebReques t2.CookieContai ner =
myHttpWebReques t.CookieContain er;
myHttpWebReques t2.AllowAutoRed irect = true;
Stream newStream = myHttpWebReques t2.GetRequestSt ream();
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 3183
lo*****@gmail.c om 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&R ef=200511221612 45 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:applicatio n/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.om nivox.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:Microsof t-IIS/6.0
X-Powered-By:ASP.NET
X-AspNet-Version:1.1.432 2
Location:https://brebeuf.omnivox.ca/estd/Veri...n1=WBuuh3CLOA%
3d%3d&n2=WRyugA %3d%3d&C=BRE&E= P&L=FRA&Ref=200 51122162802
Set-Cookie:comn=BRE ; expires=Wed, 22-Nov-2006 21:28:02 GMT; path=/
Set-Cookie:lngomn=F RA; 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&R ef=200511221612 45 HTTP/1.1
Content-Type:applicatio n/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.om nivox.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 myHttpWebReques t =
(HttpWebRequest )WebRequest.Cre ate(uri);
myHttpWebReques t.CookieContain er = new CookieContainer ();
HttpWebResponse myHttpWebRespon se =
(HttpWebRespons e)myHttpWebRequ est.GetResponse ();
myHttpWebRespon se.Close();
string postData =
"formEtudiant=o &NoDA=000000&NI P=PASS&x=0&y=0" ;
byte[] byte1 = Encoding.UTF8.G etBytes(postDat a);
HttpWebRequest myHttpWebReques t2 =
(HttpWebRequest )WebRequest.Cre ate(myHttpWebRe sponse.Response Uri);
myHttpWebReques t2.ContentType =
"applicatio n/x-www-form-urlencoded";
myHttpWebReques t2.ContentLengt h = postData.Length ;
myHttpWebReques t2.Method = "POST";
myHttpWebReques t2.CookieContai ner =
myHttpWebReques t.CookieContain er;
myHttpWebReques t2.AllowAutoRed irect = true;
Stream newStream = myHttpWebReques t2.GetRequestSt ream();
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.d e
Nov 25 '05 #2

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

Similar topics

5
4260
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 second form when it is called. Both forms are .htm files that call themselves when the submit button is press via the following command in each form: <form method="post" action="<?php $server?>">
3
2391
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 entered an error within the form the user is NOT redirected to the next page and error messages are displayed indicating the fields that are in error. So far so good. The only problem is that all the input fields are now blanked out after the...
4
10562
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 great article about the issue: http://ppewww.ph.gla.ac.uk/~flavell/charset/form-i18n.html Generally, that states that this are is filled with landmines. From my tests
8
3222
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 'search' may be clicked on by the user and the user can then search all records by postcode. I want to do this to prevent duplicate data entry.
24
2884
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 image below it.
15
33463
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 all working fine. However, when refresh the browser, I get the following message displayed: "The page you are trying to view contains POSTDATA. If you resend the data, any action the form carried out (such as as search or online purchse) will...
8
3508
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 the post and get the response. using this code: Dim PostData as string Dim ActionURL as string Dim myWebClient As WebClient = New WebClient
23
14522
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 the visitors will retype it all so i'm asking: "how to preserve POST-data when clicking the back-button?" i've already tried to print post data as a value in a HTML tag but
4
3002
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 with data from the database, allow the user to update it, and then display the form again with POST data. I can get the data out of the database and get the user updates back into the database, but how do I get the filled-out form back to the user...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10267
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10046
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7463
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4014
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.