|
Rank: Newbie Groups: Member
Joined: 10/4/2019 Posts: 5
|
Hello, I'm using AfterReceiveHeadersEvent to get "application/json" response. I can get headers, contentType, statusCode etc. But how to get json content?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi, You will not be able to get the response contents directly from the browser engine because for most pages the browser engine never has the full response contents. This is because the browser engine is highly optimized and it parses the contents chunk by chunk as it receives them. Once a chunk of the raw contents data is parsed, it is immediately discarded. If you must intercept the response contents, you can use a custom resource handler to fetch the resource in your own code in entirety, then pass this entire response down to the browser engine. Obviously this would have a negative impact on performance since it would lose both the key optimization step mentioned above, but also other optimizations by the loader layer. However it would allow you to inspect/modify the response since your code would have the response before the browser engine can have it. See here for more details on custom resource handler: https://www.essentialobjects.com/doc/webbrowser/advanced/resource_handler.aspxHope this helps. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 10/4/2019 Posts: 5
|
Thanks. But I not realy understand how to use it. How can I get json response content? Can you make example?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
I am not sure if you understand our previous reply. With EO.WebBrowser there are two options:
1. Let the browser engine handle everything. With this option, you can NOT get the response content at all (as explained above);
2. You get the content yourself first, then pass it to the browser engine. With this option the browser engine takes over after you get your content. Exactly how you get your content is up to you and would no longer have anything to do with EO.WebBrowser at all.
As you can see, if you use option 2, you will need to get the contents yourself. With this option the browser engine only display the contents for you (as oppose to option 1 it would both fetch and display the content for you).
In short, you can NOT get the contents through EO.WebBrowser.
Hope this clear it up for you.
|
|
Rank: Member Groups: Member
Joined: 10/17/2019 Posts: 14
|
gethtml ???
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
GetHTML does not get your response content. It gets the current HTML of the DOM tree. These two are very different. For example, your response content can be a small piece of JavaScript code that dynamically creates a lot of HTML content. In that case the response content is your JavaScript code but GetHtml will return you the result HTML created by the JavaScript code.
|
|
Rank: Newbie Groups: Member
Joined: 10/4/2019 Posts: 5
|
So there is no way to get response content from loaded page with your WebBrowser? In DotNetBrowser there is simple way to do it. https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000110177-accessing-http-response-data
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi,
No. We do not provide this feature because it does not give you the full response --- the delegate can be called multiple times and each time only with a chunk of data.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/17/2019 Posts: 14
|
Can Dotnetbrowser get the http-only cookie and set the new cookie in webbrowser ??? in EO if you want to get the responsebody, It looks like you can only use fiddlerapi
|
|