Welcome Guest Search | Active Topics | Sign In | Register

In which method can I view and modify the original HTML returned by the request? Options
CLRSCR
Posted: Thursday, March 18, 2021 3:19:03 AM
Rank: Newbie
Groups: Member

Joined: 8/8/2020
Posts: 4
I want to act as an intermediary to get or modify the original HTML, but I didn't find the relevant event, only the head related, but it doesn't meet my needs, please give me some advice.Thank you
eo_support
Posted: Thursday, March 18, 2021 12:52:39 PM
Rank: Administration
Groups: Administration

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

There is no specific events designed for this purpose because the browser engine does NOT download the entire HTML all together. It parses and discard chunks as they come down from the server.

However you can replace the entire loading layer with your own code use a custom resource loader. This way you would be "feeding" the browser engine so you can feed it whatever you want to. The content you feed to the browser engine can be anything, comes from a different server, changed contents based on existing contents, from a local file, completely generated on the fly in memory, etc --- it's completely up to you. See here for more details on this feature:

https://www.essentialobjects.com/doc/webbrowser/advanced/resource_handler.aspx

Thanks!
CLRSCR
Posted: Friday, March 19, 2021 4:32:40 AM
Rank: Newbie
Groups: Member

Joined: 8/8/2020
Posts: 4
I tried to use a custom resource loader, and 3 new problems appeared, which may be due to my misunderstanding.
1.After customization, it will directly enter the'ProcessRequest' event.EO.WebBrowser does not make a network request, so that the parameter'response' has no data, but I need to get the data after the network request.
2.It will pop up the save file box every time, but I don't need it.
3.I assign a value to'response', but it is not displayed on the web control.
My ideal situation is:
After EO.WebBrowser makes a normal network request, it is read (or modified) by me here, and it is returned to EO.WebBrowser for further processing and displayed on the Web control.
If I want to achieve this requirement, please give me some suggestions. Thank you
BenjaminSimpson1989
Posted: Friday, March 19, 2021 8:42:30 AM
Rank: Advanced Member
Groups: Member

Joined: 1/12/2015
Posts: 81
CLRSCR wrote:
I tried to use a custom resource loader, and 3 new problems appeared, which may be due to my misunderstanding.
1.After customization, it will directly enter the'ProcessRequest' event.EO.WebBrowser does not make a network request, so that the parameter'response' has no data, but I need to get the data after the network request.
2.It will pop up the save file box every time, but I don't need it.
3.I assign a value to'response', but it is not displayed on the web control.
My ideal situation is:
After EO.WebBrowser makes a normal network request, it is read (or modified) by me here, and it is returned to EO.WebBrowser for further processing and displayed on the Web control.
If I want to achieve this requirement, please give me some suggestions. Thank you


It's funny that you're asking the same question at the same time I need to do the same thing. It seems as if the request is never actually made by the browser. I figure you can achieve this by having something else make the actual requests (like HttpClient or another browser) and just leave your main browser as a shell issuing the requests and rendering the responses. If you find a good working solution, please share it here.
eo_support
Posted: Friday, March 19, 2021 10:25:05 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Clrsrc,

That is whole point of a custom resource loader: EO.WebBrowser will NO LONGER make the request itself because you are taking over the network loading layer. As to save file box, that's probably because you didn't set the response's ContentType.

You keep asking about the same question: how to intercept and modify the response. We have already clearly told you that this is not possible. Your choices are:

A. Let EO.WebBrowser do the network request for you. This is the default behavior;
B. Do the network loading yourself and then pass the result to EO.WebBrowser. This is what a custom resource loader is for. You can do anything you want to do with this option.

For option B, you can see the custom resource handler sample in TabbedBrowser sample application for sample code.

Thanks!
CLRSCR
Posted: Saturday, March 20, 2021 10:17:09 PM
Rank: Newbie
Groups: Member

Joined: 8/8/2020
Posts: 4
Okay, I understand, it is indeed because of "ContentType". It is my negligence. Thank you for your patience.
CLRSCR
Posted: Saturday, March 20, 2021 10:27:48 PM
Rank: Newbie
Groups: Member

Joined: 8/8/2020
Posts: 4
BenjaminSimpson1989 wrote:
CLRSCR wrote:
I tried to use a custom resource loader, and 3 new problems appeared, which may be due to my misunderstanding.
1.After customization, it will directly enter the'ProcessRequest' event.EO.WebBrowser does not make a network request, so that the parameter'response' has no data, but I need to get the data after the network request.
2.It will pop up the save file box every time, but I don't need it.
3.I assign a value to'response', but it is not displayed on the web control.
My ideal situation is:
After EO.WebBrowser makes a normal network request, it is read (or modified) by me here, and it is returned to EO.WebBrowser for further processing and displayed on the Web control.
If I want to achieve this requirement, please give me some suggestions. Thank you


It's funny that you're asking the same question at the same time I need to do the same thing. It seems as if the request is never actually made by the browser. I figure you can achieve this by having something else make the actual requests (like HttpClient or another browser) and just leave your main browser as a shell issuing the requests and rendering the responses. If you find a good working solution, please share it here.


I just understood that if a custom resource loader is used, the network request will be completely handled by myself, and I cannot use the EOWeb request and get the return value to modify the display. My second and third problem is because the "ContentType" is not set. As for the first point, your suggestion is feasible, just simulate the request and write it back to "response". This is my current solution. Thank you for your suggestion.
Code: C#
response.ContentType = "text/html";
eo_support
Posted: Sunday, March 21, 2021 10:41:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Great. Glad that you got it working!


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.