On May 16, 4:18 pm, Peter Bromberg [C# MVP]
[quoted text, click to view] <pbromb...@yahoo.yabbadabbadoo.com> wrote:
> Couple of things I see right away:
> 1) You are using the http POST verb, but all your stuff is on the
> querystring.
> That's a GET.
> 2) your content length is specified as 0 bytes.
>
> There are lots of examples of how to make a form POST with HttpWebRequest.
> Let your fingers do the googling and you'll find them very quickly.
>
> -- Peter
> Site:
http://www.eggheadcafe.com > UnBlog:
http://petesbloggerama.blogspot.com > Short urls & more:
http://ittyurl.net >
>
>
> "shantanu" wrote:
> > Hi All
>
> > I need to update some data on a web page through the httpwebrequest.
> > For which i am writing the code below . Kindly tell me where the flaw
> > is as it is not updating the values.
>
> > Thanks and regards
> > Shantanu
>
> > WebNetCred =3D new System.Net.NetworkCredential("test","test123");
> > System.Uri uriDest =3D new Uri("http://aww.n=
gn.bel.alcatel.be/prp/
> > cgi-bin/secure/DRForm.cgi?root=3DAL&number=3D9YZ-00153-
> > ABAA&mode=3Dupdate&dr0p.original=3D2003-02-28&dr0p.planned=3D&dr0p.stat=
us=3D&dr1.or=ADiginal=3D&dr1.planned=3D&dr1.status=3D&dr3.original=3D&dr3.p=
lanned=3D&dr3.status=3D&dr4=AD.original=3D&dr4.planned=3D&dr4.status=3D&dr5=
..original=3D&dr5.planned=3D&dr5.status=3D&=ADdr6.original=3D&dr6.planned=3D=
&dr6.status=3D&del1.original=3D&del1.planned=3D&del1.st=ADatus=3D&del2.orig=
inal=3D&del2.planned=3D&del2.status=3D&dr0.original=3D&dr0.planned=3D&=ADdr=
0=2Estatus=3D&dr2.original=3D&dr2.planned=3D&dr2.status=3D&obr.original=3D&=
obr.planne=ADd=3D&obr.status=3D");
[quoted text, click to view] >
> > HttpWebRequest httpRequest =3D
> > (HttpWebRequest)WebRequest.Create(uriDest);
>
> > httpRequest.Method =3D "POST";
> > httpRequest.PreAuthenticate =3D true;
> > httpRequest.Credentials =3D WebNetCred;
>
> > httpRequest.Timeout =3D 150000;
> > httpRequest.KeepAlive =3D true;
> > httpRequest.ContentType =3D "application/x-w=
ww-form-urlencoded";
> > httpRequest.ContentLength =3D 0;// bytes.Len=
gth;
> > MessageBox.Show("2");
>
> > WebResponse response =3D httpRequest.GetResp=
onse();
> > HttpWebResponse httpResponse =3D (HttpWebRes=
ponse)response;
> > System.IO.Stream stream =3D httpResponse.Get=
ResponseStream();
> > System.IO.StreamReader readStream =3D new
> > System.IO.StreamReader(stream, System.Text.Encoding.UTF8);
> > string txt =3D readStream.ReadToEnd();
> > MessageBox.Show("3");
> > readStream.Close();
> > stream.Close();
> > MessageBox.Show("txt : " + txt);
> > MessageBox.Show("4");- Hide quoted text -
>
> - Show quoted text -
Thanks peter it worked
now i have a new question
i have written a code that will send a querystring to search data from
a webpage . If the values sent in the querystring matches the data or
dosent matches the data then it sends the whole web page. ijust want
to extraxt the result from the webpage. By any chance i can get it.
i am pasting the code below
Private Function AuthenticateUser()
Dim netCred As New NetworkCredential("test", "test002")
'Dim UriDest As New Uri("
http://ldap.net.alcatel.com/Sc=3DIN?
S=3Dshantanu%20sen")
Dim httpReq As HttpWebRequest
Dim WebReq As WebRequest
'httpReq.Create(UriDest)
httpReq =3D WebRequest.Create("
http://ldap.net.alcatel.com/Sc=3DIN?
S=3Dshantanu sen")
httpReq.Method =3D "GET"
httpReq.PreAuthenticate =3D True
httpReq.Credentials =3D netCred
httpReq.ContentType =3D "application/x-www-form-urlencoded"
'httpReq.ContentLength =3D 0
Dim response As WebResponse
response =3D httpReq.GetResponse()
Dim stream As System.IO.Stream
stream =3D response.GetResponseStream()
Dim ReadStream As New System.IO.StreamReader(stream,
System.Text.Encoding.UTF8)
Dim txt As String
txt =3D ReadStream.ReadToEnd
Return (txt)
End Function