简体   繁体   English

从ASP页面上的process.start,在其中放置exe文件

[英]process.start from ASP page, where to put exe file

Just a quick question, where do I put the exe that I am trying to launch in an ASP project? 只是一个简单的问题,我要将尝试启动的exe放在哪里放在ASP项目中? It cant see it in the bin folder. 它在bin文件夹中看不到它。

You need to pass a full path to Process.Start : 您需要将完整路径传递给Process.Start

Process.Start(Server.MapPath("~/bin/whatever.exe"));

However, ~/bin/ is meant for .Net assemblies; 但是, ~/bin/用于.Net程序集; it's generally better to put external EXEs in ~/App_Data/ . 通常最好将外部EXE放入~/App_Data/

Note that you can only execute programs on the server, not the client. 请注意,您只能在服务器上执行程序,而不能在客户端上执行程序。

Remember that your Website is running on a server so if you Shell anything (Process.Start in an ASP.Net application) it will be opened on the Server - not the Client PC. 请记住,您的网站正在服务器上运行,因此,如果对任何内容(在ASP.Net应用程序中为Process.Start)进行外壳处理,它将在服务器上而不是客户端PC上打开。

Be sure you test this in production and when you do shell processes on a server (which I would not advise) dont forget to close them, otherwise you will end up with strange errors on the server. 确保在生产环境中进行了测试,并且在服务器上执行shell进程时(我不建议这样做),请不要忘记关闭它们,否则最终会在服务器上出现奇怪的错误。

To avoid security concerns and multiple process running in parallel. 为了避免安全问题和多个进程并行运行。 from asp page i would rather prefer to queue up the request for process start in some table than have other process like windows service in background to pick it up from queue and execute. 从ASP页开始,我宁愿在某个表中排队等待进程启动的请求,而不希望在后台将其他进程(例如Windows Service)从队列中提取并执行。

Path.Combine(Server.MapPath(Request.ApplicationPath), "PathToExeFromWWWRoot");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM