2014-03-29 76 views
0

嗨,大家好,我想创建一个网站[本地],它的一个能力必须采取从桌面(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 ...

回答

0

嗨,大家好我找到了一种方法来解决这个问题,我下载IIS从MS网站并设置其对ApplicationHost.config后8.0快递为我的网站路径和绑定IP端口,并给予防火墙权限,现在我可以采取我的桌面截图:D 感谢所有。

0

我的第一反应是说,这是不可能的,但因为你设法在VS做到这一点,可能是它..

要设置用户,在IIS中,您需要转到应用程序池 - >右键单击您的站点正在使用的应用程序池(默认情况下为ASP.NET V4.0集成) - >高级设置 - >找到设置称为身份,点击[...],然后在新的弹出窗口中单击单选按钮自定义帐户,并在那里设置您的用户帐户。

如果不解决这个问题,我觉得没有什么会

+0

嗨,感谢回复,它使用DefaultAppPool,那么我应该如何处理用户名和密码??????我的意思是我应该设置什么,我的意思是我必须设置我的Windows身份验证信息或其他或我想要的任何东西!在那之后,我应该怎样处理我的代码隐藏,有没有一个地方可以在代码隐藏中输入这些用户名和密码? – user3475113

+0

我设置了我的Windows用户名和密码,但我得到了同样的错误... – user3475113

+0

在这种情况下,我倾向于说这是不可能实现你的目标。尝试创建另一个控制台应用程序,您可以启动它并捕获桌面,将其保存到Web进程可以读取的位置,然后返回该图像。 –