在IIS中托管时,Sendkeys无法正常工作 [英] Sendkeys not working when hosted in IIS

查看:101
本文介绍了在IIS中托管时,Sendkeys无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个用asp.net开发的应用程序。在这里,我尝试将数据从我的应用程序(在IIS中托管)发送到另一个Web应用程序(本地计算机)。它工作正常,而我曾经在Visual Studio开发服务器中运行应用程序,但从IIS运行时获取访问被拒绝的问题。以下是我的代码。



提前致谢。







  int  iHandle = NativeWin32.FindWindow( null  发送数据的应用程序名称); 
NativeWin32.SetForegroundWindow(iHandle);
SetActiveWindow(iHandle);
System.Windows.Forms.SendKeys.SendWait( some value); // 这里我在IIS中运行时遇到访问被拒绝问题
System.Windows.Forms.SendKeys .SendWait( {TAB});
System.Windows.Forms.SendKeys.SendWait( some value);

解决方案

当您从Visual Studio中运行您的网站时,您使用的本地帐户可能具有更多访问权限,甚至是管理员......

在IIS内部,您站点的用户上下文是不同的 - 这是在站点或站点运行的池上定义的用户...默认情况下,该用户是一个非常弱的用户,可以在系统内部做很多事情(当然是安全性的原因)。

显然用户没有权利向外部进程发送WM消息...

您有两种选择:

1.首选方法是检查您的设计 - 以您描述的方式在两个应用程序之间进行交谈是一个非常糟糕的主意,但在其中一个应用程序中它甚至更糟糕是一个网站...

2.将网站/池上的用户切换到有足够权限发送WM messa的用户GES ...

Hi all,

I have an application developed in asp.net. Here i am trying to send data from my application(hosted in IIS) to another web application(local machine). Its working fine while i used to run the application in visual studio development server but getting access denied issue while running from IIS. Below is my code.

Thanks in advance.



int iHandle = NativeWin32.FindWindow(null, "Application name to send the data");
NativeWin32.SetForegroundWindow(iHandle);
SetActiveWindow(iHandle);
System.Windows.Forms.SendKeys.SendWait("some value");//Here i am getting Access denied issue while running in IIS
System.Windows.Forms.SendKeys.SendWait("{TAB}");
System.Windows.Forms.SendKeys.SendWait("some value");

解决方案

When you run your web site from within Visual Studio you use your local account, that has probably more access right,even administrator...
Inside the IIS the user context for your site is different - this is the user defined on the site or on the pool the site runs in...That user by default is a very weak user that can't do a lot of things inside the system (the reason of course is security).
Apparently the user has no right to send WM messages to external processes...
You have two options:
1. The preferred way is to review your design - it is a very bad idea to talk between two applications the way you described, but it even worst when one of the applications is a web site...
2. Switch user on the site/pool to one with enough rights to send WM messages...


这篇关于在IIS中托管时,Sendkeys无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆