The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Script/emulate browser session in .NET?

Hi, all.

We have have an off-the-shelf software utility that monitors the health of some of our servers.  This application has a web-based interface, requiring logins, passwords, group access policies, etc.

I'm trying to write a .NET page that, upon loading, will log into this monitoring application, fire off a certain URL, pick an image URL out of the request results, and then display that on the screen.

Is there a .NET library that has this "browser emulator" functionality within it?  Or, is there another application altogether that I could use .NET to script, in order to retrieve this image?

Thanks for the help,
ICCO
IVR_CTI_CRM_OMG
Wednesday, June 18, 2008
 
 
Are you just trying to get the image or do you need to make sure that the image URL is in the requested page contents? There is a big difference.

If you are just trying to make sure that your web server responds to a request for the image itself you can just make a direct request for it using something like the HttpWebRequest/HttpWebResponse classes and the URL of the desired image (ex: http://mywebserver.com/myapp/image10.gif).

If you are wanting to make sure the page contents contain an image link to the image in question you could use these same classes and then manually parse the response directly.

I don't know of any .NET classes that emulate browser behavior and give you access to the resulting DOM so that you can pull out images. Maybe you could accomplish some of this stuff using the built-in WebBrowser control. But in my experience the WebBrowser control is pretty poor because they didn't expose a lot of the inner control's functionality. I've had to use interop instead to get at some of the inner functions not directly exposed by WebBrowser.
uggh
Wednesday, June 18, 2008
 
 
Here is an example of what I am talking about.

http://www.developer.com/net/asp/article.php/3644731
uggh
Wednesday, June 18, 2008
 
 
System.Net.WebClient

or if you need something more complicated:
System.Net.HttpWebRequest/System.Net.HttpWebResponse
Joel Coehoorn Send private email
Wednesday, June 18, 2008
 
 
HttpWebRequest is cool and all but is prone to some failures....for example, if your connection gets dropped, or you run through certain proxies, etc, it can return a failed response. If you want to build allot of error checking, you can get past that, but you are talking a server-to-server call here and some knowledge of .NET.

You did mention this monitoring piece had a web interface, right? Why not create a simple html page that has an image tag in it that links to that image on that page (you will have to go grab the url - assume its not dynamic). You can stick an "onerror=somealtimagepath" attribute in that img tag that will fire if the image isnt found, and replace it with any image on your server. I assume your software is either checking presence of image or size, name, etc. This will tell you if the server failed.

This might bypass their security, unless the images are streamed down or they have certain session-based security that verify these calls.

We built our own server monitoring piece adding simple web pages that verify connections to sql and generate data and images.
Ranger
Sunday, June 22, 2008
 
 
You can use the iMacros software to script the IE or Firefox web browser: http://www.iopus.com/imacros/web-scripting.htm

It includes a COM interface instead of a native .NET interface, but we are using it from C# and it works well.
Frank Send private email
Tuesday, June 24, 2008
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz