Welcome Guest Search | Active Topics | Sign In | Register

cookies and proxies Options
happyjoe
Posted: Friday, June 27, 2014 6:48:34 AM
Rank: Newbie
Groups: Member

Joined: 6/27/2014
Posts: 2
Hi,

I recently downloaded the eo.webbrowser to replace the microsoft visual studio C# webbrowser. I'm looking to automate website tasks and I am in need of a webbrowser solution to automate these tasks using different proxies and cookies on different threads.

I'm looking to initiate each webbrowser and have each instance self contained. I am having trouble assigning cookies and proxies to an instance of EO.WebBrowser.WebView it seems like i can set the proxy and cookies gloabally which are then inherited by the "LoadUrlAndWait" method.


Is there a way to assign a proxy and cookies to an instance of EO.WebBrowser.WebView with out it being global? and if possible could you please show me the code :)

eo_support
Posted: Friday, June 27, 2014 7:50:18 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

If you want ultimate control, you can handle all the HTTP request yourself with a custom resource handler. Inside your custom resource handler, you can use whatever means/proxy/cookies as you wish. See here for more information about custom resource handler:

http://www.essentialobjects.com/doc/6/advanced/resource_handler.aspx

If you do not wish to use custom resource handler, you can attach your own cookies by handling the WebView's BeforeRequestLoad event:

http://www.essentialobjects.com/doc/6/eo.webbrowser.webview.beforerequestload.aspx

This allows you to assign cookies to each request.

Proxy settings are global. This is similar to the proxy settings in your "Internet Options" dialog. However since our library is .NET, it is per AppDomain. So you should be able to create multiple AppDomain and use different settings in each AppDomain. There is no way for you to maintain different proxy settings for different WebView instance.

Additionally, you must pay attention to threads when you use WebView. A WebView is associated to the thread in which it is created, thus you can not call any WebView method from any arbitrary thread. This usually is not an issue because the WebView is always used in the UI thread. If you must create the WebView from another thread, you can use this class:

http://www.essentialobjects.com/doc/6/eo.webbrowser.threadrunner.aspx

You can use the ThreadRunner's CreateWebView to create a new WebView in the ThreadRunner's thread (each ThreadRunner object has its own thread), and then use Post or Send method to call methods on that WebView in that thread.

Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!
happyjoe
Posted: Friday, June 27, 2014 3:30:23 PM
Rank: Newbie
Groups: Member

Joined: 6/27/2014
Posts: 2
hey, thanks for the quick response.

I think the custom resource handler suits my needs. I have spend a few hours implementing it, together using a HttpWebRequest class to make the requests to a web server and then i parse the response headers along with the response data to the following:

Headers.Add(page.response_headers); //raw headers
response.Write(page.responseData); //response document

Unfortunately it doesn't load pages correctly, without my implementation of the HttpWebRequest it works fine. But with my implementation, it seems to not be able to display images that have been downloaded by my HttpWebRequest and amended the server response to the "headers" and "response" objects. Further more websites still work but don't work as they should. Some how i don't think i'm communicating the data coming from a website well enough to the "Headers.Add" and "response.Write".


I thought I would see if you recognized the symptoms of my issues and may save me a week at staring at the problem? maybe i'm setting the objects wrong :S



eo_support
Posted: Friday, June 27, 2014 10:38:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

You can't use response.Write to write a string since your image data is not a string. You will need to use Response.OutputStream.Write to write binary data.

If that's not the problem, you can try to isolate the problem into a test project and send us the test project. Please see test project guideline here:

http://www.essentialobjects.com/forum/test_project.aspx

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.