[英]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.