tinyweb 有什么用_TinyWeb:C#中的简单Web服务器

tinyweb 有什么用

Note: This project only serves single requests at once. Try this one instead. It's better: Tiny Web Server Take 2

注意:此项目一次只能处理单个请求。 试试这个吧。 更好: Tiny Web Server Take 2

介绍 (Introduction)

Currently, the offerings for .NET enabled web servers are platform dependent, and large, intended for scalable sites. Often, they have reams of features and lots of configuration. The simplest offering, http.sys, only works on windows.

当前,支持.NET的Web服务器的产品依赖于平台,并且规模较大,旨在用于可伸缩站点。 通常,它们具有大量功能和大量配置。 最简单的产品http.sys仅适用于Windows。

The purpose of this web server is to expose a small, limited scalability server for something like a home network, or another scenario where the connection frequency is relatively low, and users are trusted.

该Web服务器的目的是为家庭网络或连接频率相对较低且用户受信任的其他情况提供小型,可扩展性有限的服务器。

It works on any .NET platform, and its component based API is simple to operate. Just drag it onto a form or a service component, wire up the events, and set the properties. Aside from the local endpoint to listen on, there is zero configuration.

它可以在任何.NET平台上运行,并且其基于组件的API操作简单。 只需将其拖动到表单或服务组件上,连接事件并设置属性。 除了要侦听的本地端点外,配置为零。

使用代码 (Using the Code)

Using the code is fairly simple:

使用代码非常简单:

using TinyWeb;
using System.Net;
...
var webServer = new WebServer(); 
webServer.ProcessRequest += new ProcessRequestEventHandler(webServer_ProcessRequest);
webServer.EndPoint = new IPEndPoint(IPAddress.Any,8080);
webServer.IsStarted = true;
...
void webServer_ProcessRequest(object sender, ProcessRequestEventArgs args)
{
    var r = args.Response;
    r.ContentType = "text/html";
    r.WriteLine("<html><h1>Hello World!</h1></html>");
}

Request has methods for getting the headers, the querystring, and the request/post stream. Response has methods for setting the response headers, and for writing the response stream.

Request具有获取标头,查询字符串和请求/发布流的方法。 Response具有用于设置响应头和写入响应流的方法。

兴趣点 (Points of Interest)

SocketUtility contains many other methods for working with sockets, especially asynchronous socket communication, including exposing awaitable methods for the primary socket operations.

SocketUtility包含许多其他用于套接字的方法,尤其是异步套接字通信,包括公开主要套接字操作的等待方法。

翻译自: https://www.codeproject.com/Tips/5165870/TinyWeb-A-Simple-Web-Server-in-Csharp

tinyweb 有什么用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值