Click here to Skip to main content
15,034,598 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.



C#
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");
Posted
Comments
Sinisa Hajnal 8-Dec-14 2:16am
   
What are you trying to do? Maybe there is different way to accomplish this...

1 solution

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...
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900