如何运行EXE文件通过ASP.net? [英] how to Run EXE file By ASP.net?

查看:117
本文介绍了如何运行EXE文件通过ASP.net?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中创建了一个页面,ASP.NET运行exe文件。我创建了一个按钮,并与下面code事件:

I created a page for ASP.NET in C# to run an exe file. I created a button and an event with the below code:

        ProcessStartInfo info = new ProcessStartInfo(@"C:\inetpub\wwwroot\Share\myfile.exe");
        info.UseShellExecute = false;
        info.RedirectStandardInput = true;
        info.RedirectStandardError = true;
        info.RedirectStandardOutput = true;

        //info.UserName = dialog.User;
        info.UserName = "username";
        string pass = "MY pass";
        System.Security.SecureString secret = new System.Security.SecureString();
        foreach (char c in pass)
            secret.AppendChar(c);
        info.Password = secret;
        Process.Start(info);   

我从编译器执行的,它通常跑了,但是当我在本地主机发布的项目中,我并没有采取行动。有什么问题?

I executed from compiler and it ran normally, but when I published my project in localhost I had no action. What is the problem?

推荐答案

那你试试?
这可能与权限的问题。默认情况下,你的网站是不是应该能够执行外部的可执行文件,因为这将是一个严重的安全隐患。也许有不同的解决问题的方法不涉及运行外部程序?

What did you try? It's probably a problem with rights. By default, your website is not supposed to be able to execute external executables, because this would be a serious security risk. Maybe there is a different solution to your problem which does not involve running an external program?

无论哪种方式,我会强烈建议不要直接从您的网站上运行的可执行文件。如果你真的要运行的程序,也许你可以写,可以收到一条消息,一个简单的Windows服务(通过WCF),那么这将在一个孤立的环境中执行程序。

Either way, I would strongly advise against running an executable directly from your website. If you really have to run the program, maybe you can write a simple windows service which can receive a message (over WCF?), which will then execute your program in an isolated environment.

这篇关于如何运行EXE文件通过ASP.net?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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