19 Aralık 2015 Cumartesi

c# sitenin görüntüsünü çekme

irst we need to add reference of Windows.Forms
Add reference
In following code snippet, I have created CaptureScreenShot() method with three parameters named url, width and height. In method body, I have initialized a new thread. Then inside the thread, I have created a new WebBrowser control and set properties of the control. We need to start a new thread for WebBrowser control and execute the thread in single threaded apartments because ASP.NET applications work in multithreaded apartments. I have called the Navigate() method to browse the URL. I have attached DocumentCompleted event handler with WebBrowser control which will be raised when web page is loaded in the WebBrowser control. In DecumentCompleted event handler body, I have called DrawToBitmap() method of WebBrowser control to get the bitmap image of the webpage. At the end, I have converted image to Base64 string by using byte array.
Namespaces
Write following method 
Now write following WebBrowser event handler
At the end, just call the method by providing parameters.
You can download entire project code sample from below link.
Download Sample Code231 downloads