I am using the below code to take print screen of my web page.
using (Bitmap bitmap = new Bitmap(620, 850))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
}
bitmap.Save(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + 1 + ".JPEG", ImageFormat.Jpeg);
}
It works fine in the development machine,but once i deploy it in the Server it gives below error
Error Message:
The handle is invalid
Source: System.DrawingError
Stack Trace: at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize)
at System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
at Secure_SearchReport.btnSearch_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
Its very urgent. Any suggestion please.......
I would guess the graphics functionality is only available in rich-client applications. (Windows Forms)
This would be a huge security issue if webpages could capture snapshots of users' desktop.
You may try VisualJS.NET, the video under http://www.visualjs.net/Tutorials/WhatisVisualJSNET.aspx page could be helpful. They using Cassini Dev server in addition to built-in VisualJS.NET features in order to demonstrate very simple remote desktop over web application.