473,466 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Save data on Website

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 = new System.Net.NetworkCredential("test","test123");
System.Uri uriDest = new Uri("http://aww.ngn.bel.alcatel.be/prp/
cgi-bin/secure/DRForm.cgi?root=AL&number=9YZ-00153-
ABAA&mode=update&dr0p.original=2003-02-28&dr0p.planned=&dr0p.status=&dr1.original=&dr1.pl anned=&dr1.status=&dr3.original=&dr3.planned=&dr3. status=&dr4.original=&dr4.planned=&dr4.status=&dr5 .original=&dr5.planned=&dr5.status=&dr6.original=& dr6.planned=&dr6.status=&del1.original=&del1.plann ed=&del1.status=&del2.original=&del2.planned=&del2 .status=&dr0.original=&dr0.planned=&dr0.status=&dr 2.original=&dr2.planned=&dr2.status=&obr.original= &obr.planned=&obr.status=");

HttpWebRequest httpRequest =
(HttpWebRequest)WebRequest.Create(uriDest);

httpRequest.Method = "POST";
httpRequest.PreAuthenticate = true;
httpRequest.Credentials = WebNetCred;

httpRequest.Timeout = 150000;
httpRequest.KeepAlive = true;
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.ContentLength = 0;// bytes.Length;
MessageBox.Show("2");

WebResponse response = httpRequest.GetResponse();
HttpWebResponse httpResponse = (HttpWebResponse)response;
System.IO.Stream stream = httpResponse.GetResponseStream();
System.IO.StreamReader readStream = new
System.IO.StreamReader(stream, System.Text.Encoding.UTF8);
string txt = readStream.ReadToEnd();
MessageBox.Show("3");
readStream.Close();
stream.Close();
MessageBox.Show("txt : " + txt);
MessageBox.Show("4");

May 16 '07 #1
2 2281
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 = new System.Net.NetworkCredential("test","test123");
System.Uri uriDest = new Uri("http://aww.ngn.bel.alcatel.be/prp/
cgi-bin/secure/DRForm.cgi?root=AL&number=9YZ-00153-
ABAA&mode=update&dr0p.original=2003-02-28&dr0p.planned=&dr0p.status=&dr1.original=&dr1.pl anned=&dr1.status=&dr3.original=&dr3.planned=&dr3. status=&dr4.original=&dr4.planned=&dr4.status=&dr5 .original=&dr5.planned=&dr5.status=&dr6.original=& dr6.planned=&dr6.status=&del1.original=&del1.plann ed=&del1.status=&del2.original=&del2.planned=&del2 .status=&dr0.original=&dr0.planned=&dr0.status=&dr 2.original=&dr2.planned=&dr2.status=&obr.original= &obr.planned=&obr.status=");

HttpWebRequest httpRequest =
(HttpWebRequest)WebRequest.Create(uriDest);

httpRequest.Method = "POST";
httpRequest.PreAuthenticate = true;
httpRequest.Credentials = WebNetCred;

httpRequest.Timeout = 150000;
httpRequest.KeepAlive = true;
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.ContentLength = 0;// bytes.Length;
MessageBox.Show("2");

WebResponse response = httpRequest.GetResponse();
HttpWebResponse httpResponse = (HttpWebResponse)response;
System.IO.Stream stream = httpResponse.GetResponseStream();
System.IO.StreamReader readStream = new
System.IO.StreamReader(stream, System.Text.Encoding.UTF8);
string txt = readStream.ReadToEnd();
MessageBox.Show("3");
readStream.Close();
stream.Close();
MessageBox.Show("txt : " + txt);
MessageBox.Show("4");

May 16 '07 #2
On May 16, 4:18 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
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 = new System.Net.NetworkCredential("test","test123");
System.Uri uriDest = new Uri("http://aww.ngn.bel.alcatel.be/prp/
cgi-bin/secure/DRForm.cgi?root=AL&number=9YZ-00153-
ABAA&mode=update&dr0p.original=2003-02-28&dr0p.planned=&dr0p.status=&dr1.or*iginal=&dr1.p lanned=&dr1.status=&dr3.original=&dr3.planned=&dr3 .status=&dr4*.original=&dr4.planned=&dr4.status=&d r5..original=&dr5.planned=&dr5.status=&*dr6.origin al=&dr6.planned=&dr6.status=&del1.original=&del1.p lanned=&del1.st*atus=&del2.original=&del2.planned= &del2.status=&dr0.original=&dr0.planned=&*dr0.stat us=&dr2.original=&dr2.planned=&dr2.status=&obr.ori ginal=&obr.planne*d=&obr.status=");
HttpWebRequest httpRequest =
(HttpWebRequest)WebRequest.Create(uriDest);
httpRequest.Method = "POST";
httpRequest.PreAuthenticate = true;
httpRequest.Credentials = WebNetCred;
httpRequest.Timeout = 150000;
httpRequest.KeepAlive = true;
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.ContentLength = 0;// bytes.Length;
MessageBox.Show("2");
WebResponse response = httpRequest.GetResponse();
HttpWebResponse httpResponse = (HttpWebResponse)response;
System.IO.Stream stream = httpResponse.GetResponseStream();
System.IO.StreamReader readStream = new
System.IO.StreamReader(stream, System.Text.Encoding.UTF8);
string txt = 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=IN?
S=shantanu%20sen")

Dim httpReq As HttpWebRequest
Dim WebReq As WebRequest

'httpReq.Create(UriDest)

httpReq = WebRequest.Create("http://ldap.net.alcatel.com/Sc=IN?
S=shantanu sen")
httpReq.Method = "GET"
httpReq.PreAuthenticate = True
httpReq.Credentials = netCred
httpReq.ContentType = "application/x-www-form-urlencoded"
'httpReq.ContentLength = 0

Dim response As WebResponse
response = httpReq.GetResponse()
Dim stream As System.IO.Stream
stream = response.GetResponseStream()
Dim ReadStream As New System.IO.StreamReader(stream,
System.Text.Encoding.UTF8)
Dim txt As String
txt = ReadStream.ReadToEnd
Return (txt)
End Function

May 17 '07 #3

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

Similar topics

4
by: Luis | last post by:
Hi, I can a big problem... because I have a byte data = new byte, and I need to save this to a field on my MySQL database (here I have a BLOB field) but ¿can I save it? because if I put: Insert...
12
by: Daniel Walzenbach | last post by:
Hi, I have a Website which allows users to input data. After they finished entering data they can click a button to save their input. Problem now is, that I have no possibility to visualize that...
0
by: Hexman | last post by:
Hello All, Its a bit more complicated than the subject line implies. A website that I use for information allows me to click on a link and their .PDF displays in IE's browser window.. Since...
0
by: Hexman | last post by:
Hello All, Its a bit more complicated than the subject line implies. A website that I use for information allows me to click on a link and their .PDF displays in IE's browser window.. Since...
3
by: sakurasyi | last post by:
hi there... can anyone help me? i'm trying to create a program that will save the information that i insert into xml files using asp. but, there is an error occur when i'm trying to save the...
3
by: fiefie.niles | last post by:
I would like to save a web page to a file and have the hyperlinks work when I bring the file back up. If the web page has a hyperlink like the following <a href="OurWeb/News/abcFile.htm">, after...
5
by: manuhack | last post by:
I've written a program in Python to get some data from a website. The data structure is as follows. Every day there are new data. For each day, there are many stocks. For each stock, there are...
10
by: Marren02 | last post by:
Hi, I recently just unsubscribed my other thread due to the fact that it went against the posting regulations... If you feel offended by what I posted, I apologize I need Code for a save...
1
by: toretto | last post by:
Hello, I have a script php that I use on my website to permit visitors to send me some email with some data, this is the html table code: <table width="730" border="0" cellpadding="0"...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.