嗨,大家好,我想创建一个网站[本地],它的一个能力必须采取从桌面(IIS运行的PC桌面,完全我的意思是服务器端桌面) ,你应该说为什么服务器端,答案是,我希望看到我的桌面从我的移动设备时,即时通讯楼下,看是否下载完成与否:d权限在IIS的asp.net本地网站
我在使用asp.net页面的代码在代码隐藏
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
// Create a bitmap of the appropriate size to receive the screenshot.
using (Bitmap bmp = new Bitmap(screenWidth, screenHeight))
{
// Draw the screenshot into our bitmap.
using (Graphics g = Graphics.FromImage(bmp))
{
g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size);
}
// Do something with the Bitmap here, like save it to a file:
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();
}
从Visual Studio运行时,它的好,它需要屏幕截图,但是当我向本地主机发布网站时,它显示此错误
'/'应用程序中的服务器错误。
句柄无效
说明:在当前Web请求的执行过程中发生未处理的异常。请查看堆栈跟踪以获取有关该错误的更多信息以及源代码的位置。
异常详细信息:System.ComponentModel.Win32Exception:句柄无效
源错误:
在当前web请求的执行过程中生成未处理的异常。关于异常的来源和位置的信息可以使用下面的异常堆栈跟踪来标识。
堆栈跟踪:
[Win32Exception(0X80004005):句柄无效] System.Drawing.Graphics.CopyFromScreen(的Int32 sourceX,的Int32 sourceY,的Int32 destinationX,的Int32 destinationY,尺寸SystemRegionSize,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 .U I.WebControls.Button.RaisePostBackEvent(字符串eventArgument)+154 System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)3707
任何知道该怎么做???????我感觉它的权限,但如何设置它们,我donno ...
嗨,感谢回复,它使用DefaultAppPool,那么我应该如何处理用户名和密码??????我的意思是我应该设置什么,我的意思是我必须设置我的Windows身份验证信息或其他或我想要的任何东西!在那之后,我应该怎样处理我的代码隐藏,有没有一个地方可以在代码隐藏中输入这些用户名和密码? – user3475113
我设置了我的Windows用户名和密码,但我得到了同样的错误... – user3475113
在这种情况下,我倾向于说这是不可能实现你的目标。尝试创建另一个控制台应用程序,您可以启动它并捕获桌面,将其保存到Web进程可以读取的位置,然后返回该图像。 –