hi guys i want to create a website[local] and one of its abilities must be taking screenshot from desktop (desktop of pc where IIS is running, totally i mean serverside desktop), you should say why serverside , answer is , i want to see my desktop from my mobile device when im downstairs to see if downloads are finished or not :D
i use this code in asp.net page in codebehind
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
using (Bitmap bmp = new Bitmap(screenWidth, screenHeight))
{
using (Graphics g = Graphics.FromImage(bmp))
{
g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size);
}
MemoryStream ms2 = new MemoryStream();
bmp.Save(ms2, System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
IMG.Src = "data:image/jpg;base64," + Convert.ToBase64String(ms2.GetBuffer());
ms2.Dispose();
}
when running from visual studio , its ok , it takes screen shots, but when i published website to local host its showing this error
Server Error in '/' Application.
The handle is invalid
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The handle is invalid
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): The handle is invalid]
System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) +781
System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize) +35
ScreenShot.capture_Click(Object sender, EventArgs e) +334
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707
any idea what to do??????? i am feeling its about permissions but how to set them , i donno...