简体   繁体   English

我可以使用2个参数从asp.net调用控制台应用exe吗?

[英]Can I call console app exe from asp.net with 2 argument?

I can call the console app from the asp.net web forms but if I have input one by one like below once I got the first argument from user input then they have another input please enter another number then user need to input another argument in console app. 我可以从asp.net Web表单调用控制台应用程序,但是如果我从用户输入中得到第一个自变量,则按如下所示逐个输入,则他们有另一个输入,请输入另一个数字,然后用户需要在控制台中输入另一个自变量应用程式。 I have 2 arguments but both will take one by one. 我有2个论点,但两者都会一一对应。 If single argument at first time then I can pass as below but with 2 I could not. 如果是第一次使用单个参数,那么我可以按以下方式进行传递,但使用2则不能。 How this possible If some one help then that would be good. 这怎么可能呢?如果有人帮助的话,那将是一件好事。 I want to pass both argument. 我想通过两个论点。

Asp.net web form ASP.NET Web表单

Process p1 = new Process();
            p1.StartInfo.FileName = "ConsoleEx.exe";   // actual file name
            p1.StartInfo.Arguments = "1 ";
            p1.StartInfo.UseShellExecute = false;
            p1.StartInfo.RedirectStandardOutput = true;
            p1.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            p1.Start();
            p1.WaitForExit();
            if (p1.HasExited)
            {
                string output = p1.StandardOutput.ReadToEnd();

                lblConsoleOutput.Text = output;

                p1.Dispose();
            }

Console App 控制台应用

 static void Main(string[] args)
    {
        int num1, num2;
        int add, sub, mul;
        float div;
        Console.Write("Enter 1st number\t");
        num1 = Convert.ToInt32(Console.ReadLine());
        Console.Write("\nEnter 2nd number\t");
        num2 = Convert.ToInt32(Console.ReadLine());}

Here is the image 这是图片 在此处输入图片说明

Redirect the standard input and stream the values by code. 重定向标准输入并通过代码流式传输值。

You can find an example here; 你可以在这里找到一个例子。 http://msdn.microsoft.com/en-gb/library/system.diagnostics.processstartinfo.redirectstandardinput%28v=vs.110%29.aspx http://msdn.microsoft.com/zh-CN/library/system.diagnostics.processstartinfo.redirectstandardinput%28v=vs.110%29.aspx

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

相关问题 如何从 Azure 应用服务连接字符串设置 ASP.Net Core exe.config 值 - How can I set an ASP.Net Core exe.config value from Azure App Service Connection String 对REST服务的WebClient调用在控制台应用程序中有效,但在asp.net中无效 - WebClient call to REST service works in console app but not in asp.net ASP.Net 通过 API 调用在服务器上运行 exe - ASP.Net run exe on server from an API call 如何从ASP.Net单击按钮调用exe文件? - How to call an exe file in button click from ASP.Net? 如何从asp.net调用jQuery函数 - How can I call a jquery function from asp.net 从ASP.NET MVC调用控制台应用程序,但不想等待响应 - Call a Console App from ASP.NET MVC, but don't want to wait for the response 我如何从asp.net页运行任何win.exe? - How can i run any win.exe from asp.net page? 通过控制台应用程序在ASP.Net Forms授权网站上进行身份验证 - Authenticate on an ASP.Net Forms Authorization website from a console app 从控制台应用程序启动ASP.NET Core 1应用程序 - Launching ASP.NET Core 1 app from console application HttpWebRequest/HttpWebResponse 仅适用于控制台应用程序而不适用于 ASP.NET - HttpWebRequest/HttpWebResponse only works from Console app not ASP.NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM