C#webbrowser和HTTP COMMANDS [英] C# webbrowser and HTTP COMMANDS

查看:102
本文介绍了C#webbrowser和HTTP COMMANDS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发ServerSide应用程序,它将通过HTTP Web面板接受shell命令。为此我在WindowsForm.Application上使用了WebBrowser。 像这样



ON服务器端我写了这个代码



 WebBrowser1.Navigate(  HTTP://localhost/commander.html); 
if (webbrowser1.document.contains( cmd))
{
process.start( @ cmd。 exe
}
if (webbrowser1.document.contains( calc))
{
process.start( @ calc.exe
}





此代码可以正常工作当在Webserver上等于cmd之类的文本时,它们会执行许多cmd.exe。并且Program不接受Web服务器上的实时更改,也不执行第二个命令calc.exe。我知道这样的程序是使用TCP套接字的最佳方法,但是我的路由器不允许我和另一台用户计算机之间的tcp连接。



和web面板看起来像< br $> b $ b

 <   pre  >  <  输入    type   =  text    id   =  commander    name   =  cmder    size   =  40  /  >  
< 输入 type = submit id = cmdsend 名称 < span class =code-attribute>shellsend / >





有什么想法吗?对不起我的英语



我尝试过:



ServerSide应用程序

 WebBrowser1.Navigate(  http:// localhost / commander.html); 
if (webbrowser1.document.contains( cmd))
{
process.start( @ cmd。 exe
}
if (webbrowser1.document.contains( calc))
{
process.start( @ calc.exe
}



AND WEBPANEL SIDE < pre lang =HTML> < pre > < 输入 < span class =code-attribute> type = text id = 指挥官 name = cmder size = 40 / >
< 输入 类型 = 提交 id = cmdsend name shellsend / >

解决方案

为什么不看一下使用的东西像'NANCY'用于你的'服务器端'应用程序,并定义一个REST接口 - 然后你可以定义一个路由



获取[/ actions / {command}] 





然后你可以运行'命令'并在REST中返回结果(可能标记为)结果/有效载荷


I am trying to develop ServerSide application, who will accept shell commands via HTTP web panel.For this i was used WebBrowser on WindowsForm.Application. Like this

ON server side i wrote this code

WebBrowser1.Navigate("http://localhost/commander.html");
if(webbrowser1.document.contains("cmd"))
{
            process.start(@"cmd.exe")
        }
 if(webbrowser1.document.contains("calc"))
{
            process.start(@"calc.exe")
        }



This code works when on Webserver equals text like "cmd" but they execute to many cmd.exe . And Program not accepts live changes on webserver, and don't execute second command "calc.exe". I know for programms like this the best way to use TCP sockets, but my router not allow tcp connections between my and another user computer.

And web panel looks like

<pre><input type="text" id="commander" name="cmder" size="40"/>
<input type="submit" id="cmdsend" name "shellsend" />



Any ideas? Sorry for my English

What I have tried:

ServerSide application

WebBrowser1.Navigate("http://localhost/commander.html");
if(webbrowser1.document.contains("cmd"))
{
            process.start(@"cmd.exe")
        }
 if(webbrowser1.document.contains("calc"))
{
            process.start(@"calc.exe")
        }


AND WEBPANEL SIDE

<pre><input type="text" id="commander" name="cmder" size="40"/>
<input type="submit" id="cmdsend" name "shellsend" />

解决方案

Why dont you look at using something like 'NANCY' for your 'server side' application, and define a REST interface - then you could define a route

Get["/actions/{command}"]



you can then run the 'command' and return the result (possibly marked up) in the REST result/payload


这篇关于C#webbrowser和HTTP COMMANDS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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