Skip to main content

Posts

Showing posts from 2024

Custom Web Browser in MVC

  we need to add webbrowser with threading other wise we will get  ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.  error this is the way we can make webbrowser work in asp.net webpages using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Threading; using System.Windows.Forms; /// <summary> /// Summary description for CustomBrowser /// </summary> public class CustomBrowser { public CustomBrowser () { // // TODO: Add constructor logic here // } protected string _url; string html = "" ; public string GetWebpage ( string url ) { _url = url; // WebBrowser is an ActiveX control that must be run in a // single-threaded apartment so create a thread to create the // control and generate the thumbnail Th