Click here to Skip to main content
15,919,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a need to automate a process where we log into a router page, (password/ID), then navigate to the various pages on the radio server, to read and update fields on the HTML pages. Keep in mind, no human intervention here. This is all done in the background via TCP/IP access. I have done this in Python using the URLlib and Clientform, and it works fine. However, I want to now do it in C#, but do not know C# very well.
I've seen some examples, but they are not detailed enough for me to grasp how to accomplish this.
I would appreciate any code snippets you can point me to.

Thanks.

PS. I am using visual studio 2010 to write this app.
Posted
Updated 1-Jul-11 6:22am
v2
Comments
Jpuckett 1-Jul-11 14:32pm    
Do you want to do this easily via a WinForms app that a batch file/scheduled task can run, or do you want to do it invisibly (and more time-consuming to make and test) via a Service?

When using the WindowsForms app you can just spawn a WebBrowser object and execute it there, but if you want to do it invisibly, you have to use the HttpWebRequest/Response objects to generate (what the website expects) the requests and responses to simulate that functionality.
Davidscott59 1-Jul-11 15:41pm    
I am writing it in a winform app. Once the "user" (test engineer) inputs the IP address, password, and username, he will then select something like "start test" button. From there on, the program runs in the background without any other intervention until its tasks are complete.
I am figuring I need to use the Httpwebrequest objects... but like I said before, I do not know C# and how to implement this. I have been researching and trying different things all day. I can get to the webpage, but it of course sends back a error 401. I need to input the credentials at this point, but not sure how.
I am trying NetworkCredential myCredentials = new NetworkCredential(username, password);
with no success.
what I need is some hand holding on this. I have had plenty of people give me suggestions of what objects to use. But what I need, is someone to "show" me how to implement these methods.
Forgive my C# ignorance here.

1 solution

Here's a step by step example of spawning a WebBrowser control, navigating to google.com, and inputting search criteria, triggering the search.

This[^] should point you in the right direction.
 
Share this answer
 
Comments
Jpuckett 1-Jul-11 23:25pm    
If you need more help after this; just give me a comment back, I'm email monitoring this thread.
Davidscott59 3-Jul-11 12:31pm    
Thanks, I will give this a try. FYI, I can do all of this via python in about half the amount of code it takes with C#. I may stick with the python...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900