1

Increasing height of WebBrowser using asp.net c# code then getting error:

Parameter is not valid.

below is my code for taking screenshot of the page



    private void webbrowse_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        WebBrowser webrowse = sender as WebBrowser;
        Bitmap bitmap = new Bitmap(webrowse.Width, webrowse.Height);
        webrowse.DrawToBitmap(bitmap, webrowse.Bounds); //geting error in this line

        MemoryStream stream = new MemoryStream();
        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
        byte[] strbytes = stream.ToArray();
        imgscreenshot.Visible = true;
        imgscreenshot.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(strbytes);    

    }

if I will increase the height of webrowser.Height = 20000; in above GenerateThumbnail method then getting error :Parameter is not valid. I have 20 pages height in my aspx page thats why want to increase the height. I am not able to increase long size height.

mohd mazhar khan
  • 103
  • 1
  • 9
  • 37
  • bro if 5000 height value then output coming, but if i will increase the height from 5000 to 20000 height then getting error. @JesúsNarváezTamés – mohd mazhar khan Aug 08 '19 at 10:37
  • Take a look to this thread. They speak about the memory restrictions for bitmaps.https://stackoverflow.com/questions/29175585/what-is-the-maximum-resolution-of-c-sharp-net-bitmap – Mr.Deer Aug 08 '19 at 10:39

1 Answers1

1

After looking for a while with @Mohd Mazhar Khan there is a solution:

The iss express was in 32-bit and it should be configured in 64-bit for manage big amounts of memory.

For changing the settings is this way:

Tools>Options>Projects and Solutions>Web Project and check the 64-bit IISEXPRESS box.

Mr.Deer
  • 434
  • 5
  • 15