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.