简体   繁体   English

System.Windows.Forms.Clipboard 适用于桌面,但不适用于 IIS

[英]System.Windows.Forms.Clipboard works on desktop, but does not work on IIS

I have a small module, which is looking for an image in the clipboard and if it is there, displays it on the page.我有一个小模块,它正在剪贴板中寻找图像,如果存在,则将其显示在页面上。 This works great in my desktop, but never gets into System.Windows.Forms.Clipboard.ContainsImage() when hosted on IIS.这在我的桌面上效果很好,但在 IIS 上托管时永远不会进入 System.Windows.Forms.Clipboard.ContainsImage() 。 Any concept that beats the purpose, like a windows clipboard cannot be used by server side application?服务器端应用程序不能使用任何超出目的的概念,例如 Windows 剪贴板?

        if (System.Windows.Forms.Clipboard.ContainsImage())
        {
            img = System.Windows.Forms.Clipboard.GetImage();
            imgBytes = imageToByteArray(img);
            string imgString = Convert.ToBase64String(imgBytes, 0, imgBytes.Length);                
            clipBoardImg.ImageUrl = "data:image/jpeg;base64," + imgString;
            clipBoardImg.Visible = true;
        }

If you try to access the clipboard on IIS, you try to access it on the server , not on the client.如果您尝试在 IIS 上访问剪贴板,您将尝试在服务器上访问它,而不是在客户端上。 This will most definitely fail server-side too since you don't have a screen in your server process (you are not user-interactive).这肯定也会在服务器端失败,因为您的服务器进程中没有屏幕(您不是用户交互的)。

The thing you should do is convert this code to something client side (javascript for example), which is hard since you can't just access the clipboard from the clients browser.您应该做的是将此代码转换为客户端(例如javascript),这很难,因为您不能仅从客户端浏览器访问剪贴板。

I think it is (almost) impossible to get this implemented.我认为(几乎)不可能实现这一点。 Would the use of a input type=file help you?使用input type=file对您有帮助吗? Or a drag-drop surface ?还是拖放表面 This seems the better options to me.这对我来说似乎是更好的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 复制到没有System.Windows.Forms.Clipboard的剪贴板吗? - Copy to clipboard without System.Windows.Forms.Clipboard? 防止C#System.Windows.Forms.Clipboard对象在双击时打开 - Preventing a C# System.Windows.Forms.Clipboard object from opening on double-clicking 为什么System.Windows.Forms BeginInvoke在WPF中似乎可以工作 - Why does System.Windows.Forms BeginInvoke seem to work in WPF C# - System.Windows.Forms.Clipboard.GetDataObject()没有响应 - C# - System.Windows.Forms.Clipboard.GetDataObject() doesnt response .net core 2.1 Web应用程序可在Visual Studio中使用,但在Windows 10中部署到IIS时无法使用 - .net core 2.1 web app works in visual studio but does not work when deployed to IIS in windows 10 System.Windows.Forms.Timer不存在 - System.Windows.Forms.Timer does not exist C#:System.Windows.Forms.SendKeys.SendWait不适用于路径作为输入 - C#: System.Windows.Forms.SendKeys.SendWait does not work with the path as input 将Datagridview复制到Windows窗体中的剪贴板 - Copy Datagridview to clipboard in Windows Forms 命名空间系统中不存在“表单”。windows - 'Forms' does not exist in the namespace system.windows Windows Forms桌面快捷方式 - Windows Forms Desktop Shortcut
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM