By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,168 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,168 IT Pros & Developers. It's quick & easy.

Posting a public web page.

P: n/a
I need to be able to create a class in C# that will allow me to navigate to a
public website "www.arin.net" (American Registry for Internet Numbers). The
web page has a single text box where I can input an IP address. Then I have
to press a button called "Search WHOIS". Then in the next page, I will get
the name and address of the entity that owns that IP address. How can I
simulate the actions of entering a value in a text box and pressing the
button to do the search? I do not have access to the underlying application
for "www.arin.net", so I could not use a code behind C# program to directly
assign a value to the ".Text" property of the text box, and then capture a
"button_click" event to do an ASP page postback. So how can I perform a
similar action on a public web page, but using C#? Should I use one of the
new C# classes like "WebRequestMethods.Http.Post"? I am a junior level
developer, so if you can give me as much coding detail as possible, I would
be very grateful. Thank you.
--
Basil Eliopoulos
Apr 5 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Basil,

When you submit form information, it's nothing more than just packaging
up the details in the proper request.

What youw ant to do is look at the HTML for the page. Look for the form
element that has the button in it that you click, as well as the textbox.
The textbox is an input element. The name attribute on that element is part
of the value you have to send to the server.

On the form element, you have an "action" attribute. This attribute has
the URL that the information is sent to.

Once you have all of this information, you can create an HttpWebRequest
instance (through the static Create method on the WebRequest class, passing
the URL in the action attribute). Then, you would call GetRequestStream and
write the name/value pair to the stream (the name being the name of the text
field, the value being the HTML encoded value you would put in the textbox).
Then, you call GetRequest and you would be able to read the stream which
contains the HTML.

Oh, last thing, you will need to set the content type header to
"x-www-application-urlencoded" as well.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Basil Eliopoulos" <be*********@community.nospam> wrote in message
news:57**********************************@microsof t.com...
I need to be able to create a class in C# that will allow me to navigate to
a
public website "www.arin.net" (American Registry for Internet Numbers).
The
web page has a single text box where I can input an IP address. Then I
have
to press a button called "Search WHOIS". Then in the next page, I will get
the name and address of the entity that owns that IP address. How can I
simulate the actions of entering a value in a text box and pressing the
button to do the search? I do not have access to the underlying
application
for "www.arin.net", so I could not use a code behind C# program to
directly
assign a value to the ".Text" property of the text box, and then capture a
"button_click" event to do an ASP page postback. So how can I perform a
similar action on a public web page, but using C#? Should I use one of
the
new C# classes like "WebRequestMethods.Http.Post"? I am a junior level
developer, so if you can give me as much coding detail as possible, I
would
be very grateful. Thank you.
--
Basil Eliopoulos

Apr 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.