|
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
|
|
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.aspxThanks!
|
|
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
|
|
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.
|
|
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!
|
|
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.
|
|
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";
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Great. Glad that you got it working!
|
|