从ASP.NET应用程序中运行控制台应用程序文件(.exe)(IIS 7.5) [英] Run console application (.exe) from within ASP.NET application (IIS 7,5)

查看:143
本文介绍了从ASP.NET应用程序中运行控制台应用程序文件(.exe)(IIS 7.5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 2008 R2的ASP.NET应用程序(.NET框架4.0,IIS 7.5),我想运行一个控制台应用程序,当我点击网页上的按钮。这里是code:

I have an ASP.NET application on Windows 2008 R2 (.NET Framework 4.0, IIS 7.5) and I want to run a console application when I click a button on a web page. Here is the code:

protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string fileLocation = @"D:\DTDocs\App_Code\LoadDTDocsXML.exe";
        ProcessStartInfo oStartInfo = new ProcessStartInfo();
        oStartInfo.FileName = fileLocation;
        oStartInfo.UseShellExecute = false;
        Process.Start(oStartInfo);
}

当我从Visual Studio 2010(其内部IIS)中运行ASP.NET应用程序,控制台应用程序运行确定。但是,当我运行VS 2010以外的ASP.NET应用程序,我没有错误,但控制台应用程序不会使他的工作(必须在磁盘上创建一个XML文件)。
我认为这个问题是IIS 7.5的配置,我也不确切知道要占我必须给访问权限,参与我的控制台应用程序的文件夹。
在IIS 7.5,我设置的物理路径凭据的对的特定用户的=我的Windows帐户,但没有解决问题。
谢谢你。

When I run ASP.NET application from within Visual Studio 2010 (with its internal IIS), the console application run Ok. But when I run the ASP.NET application outside the VS 2010, I haven't an error but the console application doesn't make his job (it must create an xml file on the disk). I think the problem is the configuration of IIS 7.5, I don't know exact to which account I must give access rights to the folders involved in my console application. In IIS 7.5, I set Physical Path Credential for Specific User = my windows account, but that not solve the problem. Thanks.

推荐答案

我想补充其他2答案 - 你的真正的需要从您的网络服务器上运行的EXE文件

Just to add to the other 2 answers - Do you really need to run an exe from your webserver?

我已经做在过去,它几乎总是不得已的选择 - 这大大削弱你的安全性(现在所有总得有人做你的系统上运行的可执行文件是在你的$ C找到一个单一的缺陷$ c)及有其它问题一大堆(网络服务器是不是登录到服务器,因此它不具有台式机,模拟是在一个$$得到正常工作的一个真正的痛苦(假设你是打算运行具有不同权限的可执行文件到web服务器)等。

I've had to do it in the past and it's almost always the option of last resort - It weakens your security considerably (Now all someone has to do to run executables on your system is find a single flaw in your code) and has a whole host of other problems (the webserver isn't "logged on" to the server so it doesn't have a desktop, impersonation is a real pain in the a$$ to get working properly (assuming you're going to run the executable with different permissions to the webserver), etc.

如果有任何其他的方式来实现自己的目标,这几乎肯定会更简单。

If there's any other way to accomplish your goal, it'll almost certainly be simpler.

我们去了一个选项是有一个新的应用程序与WCF端点的网络服务器能与沟通。所以,当有人按下按钮时,WS调用的我们通过WCF的应用程序,并告诉它来运行各种命令。通过这种方式,你有:

An option we went for was to have a new app with a WCF endpoint that the webserver can communicate with. So, when someone pushes the button, the WS call's our app via WCF and tells it to run various commands. This way, you've got:


  • 网络和控制台code之间的分离干净。

  • 一个狡猾的控制台应用程序将无法取下来的web服务器和放大器;反之亦然

  • 如果控制台应用程序是长时间运行,这使您可以错开您的网站/控制台应用程序的版本,这样你不杀应用程序中期执行,只是因为你还需要多达upodate一些CSS和发布。

  • 巨大的安全利益 - Web服务器不能即使妥协运行可执行文件

  • 的WCF应用程序将能够仔细检查请求,以确定它们是否执行之前有效。

要知道无论你做,如果有人恶意的作品发生了什么事情上,并且可以揭开序幕的过程中,他们也许可以拒绝你几乎为零的努力 - 确保这个方法很紧锁定

Be aware that however you do it, if someone malicious works out what's going on and can kick off the process, they could probably DoS you with almost zero effort - Make sure that this method is locked down TIGHT.

编辑:看了上面的你的意见,我觉得你打的桌面的问题。当启动从服务器可执行文件,以登录用户的登录用户的桌面上不可访问从IIS,反之亦然应用程序将永远是可见的。这非常类似于上具有一个窗口服务的GUI的问题。

having read your comments above, I think you're hitting the "desktop" issue. When launching an executable from the server, the app will never be visible to the logged on user as the logged on user's desktop isn't accessible from IIS and vice-versa. This is very similar to the issue of having a GUI on a windows service.

<一个href=\"http://stackoverflow.com/questions/1577697/using-asp-net-to-launch-an-application-on-the-server-on-a-specific-desktop\">This也可能是感兴趣的。

这篇关于从ASP.NET应用程序中运行控制台应用程序文件(.exe)(IIS 7.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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