0

I want to make a screenshot of a full webpage in my web application. I found a way to do this using the WebBrowser class, from the example over here (the accepted answer).

However, the WebBrowser class is located in the System.Windows.Forms namespace, and I therefore feel unsure about, whether it's okay to use this namespace in a web application. If not what will be the right approach to do this?

Community
  • 1
  • 1
mrturtle
  • 277
  • 3
  • 10
  • 3
    How would your (WinForms) code on the server be able to see the client's browser? – Uwe Keim Aug 17 '15 at 07:50
  • 1
    It is not the client's browser I'm taking screenshots of - I'm just taking screenshots of public webpages like microsoft.com. – mrturtle Aug 17 '15 at 07:54
  • 1
    OK, I see. Personally, I would never dare to use WinForms stuff on the server, since possible dangling dialogs/message boxes could stall my web application without me ever recognizing. – Uwe Keim Aug 17 '15 at 07:55
  • I do use a (commercial) library called "[HiQPdf](http://www.hiqpdf.com/)" that seems to use a Chromium/Webkit internally to render web pages to PDF. I think you could use something similar (if not the same) to achieve what you want. Possible this tool is safe to use from within a web application. [Here is an online demonstration on how to render to an image](http://www.hiqpdf.com/demo/ConvertHtmlToImage.aspx). – Uwe Keim Aug 17 '15 at 07:58
  • 1
    The warning is slightly diluted in [System.Windows.Forms](https://msdn.microsoft.com/en-us/library/system.windows.forms(v=vs.110).aspx): "Classes within the Windows Forms namespace are not supported for use within a Windows service". In other places, it's specifically called out that, of course, ASP.Net applications run within services but here you have to draw the inference yourself. – Damien_The_Unbeliever Aug 17 '15 at 07:59

0 Answers0