PDA

Click to See Complete Forum and Search --> : Simulate browser activity with C#


daluu
Aug 1st, 2006, 01:32 PM
I've used the HTTPWebRequest & Response classes briefly to retrieve an resource. But I'd like to integrate use of these classes with a temporary cookie to achieve persistence (for web servers that use sessions with session ID stored in client cookie). I was able to do this in Perl but I'd like to do the same thing in C#. This is what I would like to achieve in terms of simulating browser activity. Can someone provide me the code framework for this?

1. Create web client/user agent instance (to simulate browser).
2. Create a temporary cookie for the web client to handle storage of session IDs used by web server to be connected to.
3. Perform an HTTP GET on some desired webpage with response stored to a variable.
4. Perform an HTTP POST of (simulated) form data consisting of several form fields & their values to another webpage with response stored in another variable.
5. close connection & cleanup where necessary.

NOTE: Steps 3 & 4 happen within the same session. And could be repeated to access different URLs before we get to step 5.

Thanks for any help in advance.