2014-03-29 78 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進程可以讀取的位置,然後返回該圖像。 –