asp.net中的命令提示符 [英] command prompt in asp.net

查看:84
本文介绍了asp.net中的命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

i有一个小asp.net程序,在这个程序中我可以在我的asp.net应用程序中编写和运行命令提示命令这个故事的一个重要部分是运行exe文件命令

这是我的代码,但不要运行exe文件,例如我写mspaint它不打开

hello
i have a little asp.net program that in this program i could write and run commands of command prompt in my asp.net application An important part of this story is to run exe files with commands
it is my code but dont run exe file for example where i write mspaint it dont open

try
       {
           Process p = new Process();
           p.StartInfo.CreateNoWindow = false;

           p.StartInfo.FileName = c_path.Value = Encoding.Default.GetString(Convert.FromBase64String(c_path.Value));
           c_text.Value = Encoding.Default.GetString(Convert.FromBase64String(c_text.Value));
           p.StartInfo.Arguments = c_text.Value;
           p.StartInfo.UseShellExecute = false;
           p.StartInfo.RedirectStandardInput = true;
           p.StartInfo.RedirectStandardOutput = true;
           p.StartInfo.RedirectStandardError = true;

           p.Start();

           string[] Uoc = new string[20];
           for (int i = 1; Uoc.Length > i; i++)
           {
               Uoc[i] = p.StandardOutput.ReadLine();
               Uoc[i] = Uoc[i].Replace("<", "<");
               Uoc[i] = Uoc[i].Replace(">", ">");
               Uoc[i] = Uoc[i].Replace("\r\n", "<br>");


           }

           string txt = "";
           foreach (var item in Uoc)
           {
               txt += item + "<br />";
           }
           cmd_response.InnerHtml = "<hr width=\"100%\" noshade/><pre>" + txt + "";
           cmd_response.Visible = true;
           more.Visible = true;

       }
       catch (Exception error)
       {
           xseuB(error.Message);
       }

推荐答案

是的。

但是...... C#代码在服务器上执行,而不是客户端。因此,您通过Process.Start运行的任何应用程序都在服务器上运行,而不是客户端 - 因此会发生两件事:



1)你的用户看不到它。

2)你的网站管理员开始对你生气...



你除非出于安全原因在绝大多数情况下不会出现的特定条件,否则不能直接在客户端上执行应用程序。想想看:你的客户可能在iPad上 - 例如Windows应用程序无法运行......
Yes it does.
But...C# code executes on the server, not the client. So any application you run via Process.Start runs on the Server, not the Client - so two things happen:

1) Your user cannot see it.
2) Your web admin starts to get annoyed with you...

You cannot execute an application directly on the client except under specific conditions which do not occur in the vast majority of circumstances for security reasons. Think about it: your client could be on an iPad for example - Windows apps will not run...


这篇关于asp.net中的命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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