在ExpressJs中,您可以快速设置Web服务器并使其侦听请求,并在行内注册处理程序。
使用中间件,是否可以在ASP.NET Core中完成此操作?
能够在同一进程中启动多个Web监听器也会很方便:
非常方便。
var express = require('express')
var app = express()
// respond with "hello world" when a GET request is made to the homepage
app.get('/', function (req, res) {
res.send('hello world')
})
使用中间件,是否可以在ASP.NET Core中完成此操作?
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.Get("/api/v2/", () =>
{
return "Hello world";
});
//configure more services...
}
能够在同一进程中启动多个Web监听器也会很方便:
using (var server = new WebServer(url))
{
server.Get("/path", () => { return "Hello world" });
server.Get("/path2", () => { return "Hello world2" });
server.RunAsync();
}
非常方便。