这个是我在控制台写的代码 可以通过HTTPGET传入name参数
我现在要实现在winform下
显示到list中,且url的每个参数作为list的一个column试着做个类似日志滚动的效果,就是你每请求一次URL,日志监控窗口滚动一条。求高手解答 谢谢
//创建HttpListener对象
using (HttpListener hlistener = new HttpListener())
{
//获取设置用户端身份验证
hlistener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
//设置url前缀
//hlistener.Prefixes.Add("http://localhost:8080/web/");
//通过IP来访问
hlistener.Prefixes.Add("http://+:8080/web/");
//接收传入请求
hlistener.Start(); while (true)
{
//等待传入请求
HttpListenerContext hlc = hlistener.GetContext();
//设置返回给客户端Http状态代码
hlc.Response.StatusCode = 200;
//获取客户端信息
string name = hlc.Request.QueryString["name"];
//进行验证判断
//if (name != null)
//{
//}
//写入流输出http响应的信息
using (StreamWriter sw = new StreamWriter(hlc.Response.OutputStream))
{
sw.WriteLine(name);
sw.Close();
hlc.Response.Close();
}
}
//停止接收
hlistener.Stop();WinForm
我现在要实现在winform下
显示到list中,且url的每个参数作为list的一个column试着做个类似日志滚动的效果,就是你每请求一次URL,日志监控窗口滚动一条。求高手解答 谢谢
//创建HttpListener对象
using (HttpListener hlistener = new HttpListener())
{
//获取设置用户端身份验证
hlistener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
//设置url前缀
//hlistener.Prefixes.Add("http://localhost:8080/web/");
//通过IP来访问
hlistener.Prefixes.Add("http://+:8080/web/");
//接收传入请求
hlistener.Start(); while (true)
{
//等待传入请求
HttpListenerContext hlc = hlistener.GetContext();
//设置返回给客户端Http状态代码
hlc.Response.StatusCode = 200;
//获取客户端信息
string name = hlc.Request.QueryString["name"];
//进行验证判断
//if (name != null)
//{
//}
//写入流输出http响应的信息
using (StreamWriter sw = new StreamWriter(hlc.Response.OutputStream))
{
sw.WriteLine(name);
sw.Close();
hlc.Response.Close();
}
}
//停止接收
hlistener.Stop();WinForm
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货