How to put WebBrowser object into ASP.NET page
Hey guys, here's a unique problem I have to solve: I have a program which opens up a webpage through a WebBrowse开发者_C百科r object in c#, and does a bunch of operations with it. Now I need to integrate this functionality into my own webpage. That means that either I need to take the c# code, and somehow make it work in my webpage itself (put in a WebBrowser object, set up event handlers, etc), or I need to somehow have my webpage open this program on my server, fire an event to start, and receive input from it. It is very important for me to use a WebBrowser object (or even WebKit.Net) because there is a lot of javascript, etc on the page that needs to be processed.
Any ideas on how to pull this off?
I expect that you'll have a problem running a Windows Forms control inside a process that has no Windows message pump. I don't think this will work directly within an ASP.NET site.
On the other hand, you can place the control and the code to manipulate it into a Windows Forms application, which can then host a WCF service. The ASP.NET application can request that the Windows Forms application do the manipulation of the control on its behalf.
Of course, you'll need to handle concurrency and state issues. If there are two requests from two different users at the same time, then you'll probably want separate instances of the WebBrowser control to handle them. If request 2 depends on what happened during request 1, then you've got state issues, and you'll need request 2 to use the same WebBrowser instance that was used for request 1.
This does not sound like fun. Instead, it sounds like an attempt to use a desktop design in a web application - that typically fails.
精彩评论