Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7443253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:18:09+00:00 2026-05-29T11:18:09+00:00

I am using the web browser control in a console application, it is created

  • 0

I am using the web browser control in a console application, it is created programatically. It gets passed a url and saves the page as an image file using DrawToBitmap.

It seems to work fine for many URLs but not for some, including http://www.google.co.uk where it saves a blank page. IBM.com and microsoft.com work, think it might have something to do with the site doing a redirect.

This is the code:

 int width = -1;
        int height = -1;

        // Load the webpage into a WebBrowser control
        WebBrowser wb = new WebBrowser();
        wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
        wb.Navigated += new WebBrowserNavigatedEventHandler(wb_Navigated);

        wb.AllowNavigation = true;
        wb.ScrollBarsEnabled = false;
        wb.ScriptErrorsSuppressed = true;
        wb.Navigate(url);

        while (wb.ReadyState != WebBrowserReadyState.Complete)
        {
            Debug.WriteLine("Loading loop..");
            Application.DoEvents();
        }



        // Set the size of the WebBrowser control
        wb.Width = width;
        wb.Height = height;

        if (width == -1)
        {
            // Take Screenshot of the web pages full width
            wb.Width = wb.Document.Body.ScrollRectangle.Width;
        }

        if (height == -1)
        {
            // Take Screenshot of the web pages full height
            wb.Height = wb.Document.Body.ScrollRectangle.Height;
        }

        // Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
        Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
        wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
        wb.Dispose();

        bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
        Debug.WriteLine("Saved");
        Application.Exit();

Any ideas why some sites don’t work?

Thanks for your time

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:18:10+00:00Added an answer on May 29, 2026 at 11:18 am

    You are probably trying to save it before it has completed loading, detecting if WB is fully loaded is the biggest problem of the WB control, i have developed several methods over the years, so it involved a lot of work, and there are various methods you will need to implement.

    Also, don’t forget, some HTML data may be loading in a frame, so you may need to get a reference to teh frame and do the same thing for each frame and all frames in those frames (nested frames infinitely nested must be detected and added to your object reference to use) – frame referencing is also needed for reliable loading complete detection, checking readystate or .busy alone is insanely unreliable, your code will break almost certainly most of the time. Check out some of my WB related posts for more, or this: Webbrowser Control Limitations

    Also, if you want more help, let me know, I can give you pointers on methods of detecting loading complete.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the web browser control in an application to display a report. The
I can authenticate Facebook for desktop application using web browser control. But I want
I am using a web browser control that display html page in window form
I'm using a Web Browser Control in a C# Winform Application. I'm loading local
i am using Microsoft web browser control in an MFC Application. It displays a
Using Web Browser control or http request in C#, when a website creates a
is any light weight browser control available for c# application other than builtin web
I am using the web browser control from shdocvw.dll to build an html and
This question: Using Proxy with web browser control Told me to use InternetSetOption. How
We're using SHDocVw.dll for providing a web browser control to some of our users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.