You do not get the displayed image of the page using webRequest, you only get HTML code.
To generate the image, follow this code (ripped directly from this post )
public Bitmap GenerateScreenshot(string url) { // This method gets a screenshot of the webpage // rendered at its full size (height and width) return GenerateScreenshot(url, -1, -1); } public Bitmap GenerateScreenshot(string url, int width, int height) { // Load the webpage into a WebBrowser control WebBrowser wb = new WebBrowser(); wb.ScrollBarsEnabled = false; wb.ScriptErrorsSuppressed = true; wb.Navigate(url); while (wb.ReadyState != WebBrowserReadyState.Complete) { 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 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(); return bitmap; }
Here are some examples of using the above method:
// Generate screenshot of a webpage at 1024x768 resolution Bitmap screenshot = GenerateScreenshot("http://pietschsoft.com", 1024, 768); // Generate screenshot of a webpage at the webpage full size (height and width) screenshot = GenerateScreenshot("http://pietschsoft.com"); // Display screenshot in PictureBox control pictureBox1.Image = thumbnail; /* // Save screenshot to a File screenshot.Save("screenshot.png", System.Drawing.Imaging.ImageFormat.Png); */
source share