Using WebRequest to post data after page found.

Posted on 2005-04-25
Last Modified: 2011-09-20

I'm trying to access (screen scrape) a secure web page (have that working) that contains some radio button options.  Problem is how do I post and trigger the radio button after I pull the HTML from the secure site?

Here's the code and the output so far:

String MyURI = "";
WebRequest WReq = WebRequest.Create(MyURI);

NetworkCredential cred = new NetworkCredential("id", "pass");
WReq.Credentials = cred;

Stream objStream;
objStream = WReq.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStream);

string sLine = "";
int i = 0;
while (sLine!=null) {
      sLine = objReader.ReadLine();
      if (sLine!=null)


I get the following back:

2:<form action=/cgi-bin/orders/ METHOD=POST>
3:<input type=radio name=file value="check-form-log.txt">check-form-log.txt<br>
4:<input type=radio name=file value="booking-form-log.txt">booking-form-log.txt<br>
5:<input type=radio name=file value="contactus-form-log.txt">contactus-form-log.txt<br>
6:<input type=radio name=file value="contest-form-log.csv">contest-form-log.csv<br>
7:<input type=radio name=file value="contest-form-log.txt">contest-form-log.txt<br>
8:<input type=radio name=file value="feedback-form-log.txt">feedback-form-log.txt<br>
9:<input type=radio name=file value="submitlink-log.txt">submitlink-log.txt<br>
10:<input type=radio name=file value=".htaccess">.htaccess<br>
11:<input type=submit></form>

So at this point what do I post/submit and how do I set up WebRequest to do it?

Any pointers would really be appreciated.



Question by:sads
    LVL 37

    Accepted Solution

    by: gives an example with webclient.
    LVL 37

    Expert Comment

    for radio buttons its ... name=value in post data.


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now