dotnetcore Http服务器研究(一)

栏目: 后端 · 发布时间: 7年前

自从dotnet core 诞生以来,发展非常强势。我们总有些需要写一个独立的http服务器的需求,我想是时候忘记httplistener 了。

dotnet framework 时代建一个小的http服务器 最常用的 工具 就是 HttpListener了。

现在是dotnet core的时代,asp.net 也有了一个官方提供的 selfhost 实现kestrel。

我们来研究一下kestrel的aspnetcore 怎么用

他的基本使用非常简单,任意创建一个dotnet core项目

首先nuget 引用如下库

dotnetcore Http服务器研究(一)

microsoft.aspnetcore.app

microsoft.aspnetcore.server.kestrel

你在网上看到的asp.net core的代码都是链式调用,我不是很喜欢这种写法,但是没办法,这个每一个操作之后,host对象其实会发生变化,拆开写就得写一堆host=

dotnetcore Http服务器研究(一)

aspnetcore的基本使用方法就是这样,代码你可以找到很多,想看代码直接去我的仓库吧

https://github.com/lightszero/lightchain


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Algorithms to Live By

Algorithms to Live By

Brian Christian、Tom Griffiths / Henry Holt and Co. / 2016-4-19 / USD 30.00

A fascinating exploration of how insights from computer algorithms can be applied to our everyday lives, helping to solve common decision-making problems and illuminate the workings of the human mind ......一起来看看 《Algorithms to Live By》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

html转js在线工具
html转js在线工具

html转js在线工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具