Click here to Skip to main content
15,894,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I am hosting a web browser control within a C# application

The website I am navigating to sends a POST upon clicking a link and it receives a set of results in JSON.

Is there any way that I can send the POST request on behalf of the browser control and still have the browser receive and process the response? As if the user had clicked the link...

Thanks in advance for any assistance!
Posted

1 solution

Basically, I can see two different possibilities.

First, you can send HTTP request using the page presented in the WebBrower control instance, using Javascript and Ajax: http://en.wikipedia.org/wiki/Ajax_%28programming%29[^].

A very convenient way would be using jQuery .Ajax():
http://api.jquery.com/jquery.ajax[^].

Also, you can send an HTTP request directly, outside of WebBrowser, using the instance of System.Net.HttpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.110%29.aspx[^].

You can then receive HTTP response, parse it if it is required, and use this data to directly modify the DOM tree of your instance of WebBrower.

Unfortunately, you won't be always able to freely mix the requests from different instances. For example, if you perform authentication using HttpWebRequest instance, you cannot assume that the Web application treats your browser's client as authenticated; it will be a different session.

—SA
 
Share this answer
 
Comments
IceUK 15-Oct-14 13:13pm    
Thank you.
Sergey Alexandrovich Kryukov 15-Oct-14 13:20pm    
You are very welcome.
Good luck, call again.
—SA
Maciej Los 15-Oct-14 15:40pm    
+5!
Sergey Alexandrovich Kryukov 15-Oct-14 15:43pm    
Thank you, Maciej.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900