I want to navigate a website, login and fill a form through my application without seeing users anything and finally show it to users for submitting.
Previously I used webbrowser control. It works usually but sometimes, some error raised on site after user submit form. but in IE this errors not raised with same data.
Is there any way to navigate and fill forms with my data in IE directly and then show it to users? (this site has so many client side controls that I must wait to respond them to my data (for example load cities after select state)
You can automate an instance of Internet Explorer from your C# app. First, create the interop assembly
SHDocVw.dll
withTlbImp.exe ieframe.dll
and add it as a reference to your project. Then use the following code to create an out-of-process instance of Internet Explorer:Use it in a similar way you used
WebBrowser
control.That said, I believe you still can use hosted
WebBrowser
for what you want to achieve, just implement feature control to make it behave the same way IE does (or as close as possible).[EDITED] This innocent example may however have a hidden catch. Because you automate an out-of-proc COM object here, its events (if you handle any) may arrive on a thread, different from your main UI thread. Generally, you'd need to marshal them back to your main thread using Control.Invoke or SynchronizationContext.Post/Send (depending on whether you want to handle them asynchronously or synchronously). Here's an example of handling DocumentComplete and taking care of threading: