Server in ASP.NET-Core
.NET-Core Series
- Server in ASP.NET-Core
- DI in ASP.NET-Core
- Routing in ASP.NET-Core
- Error Handling in ASP.NET-Core
- WebSocket in ASP.NET-Core(一)
- WebSocket in ASP.NET-Core(二)
- To be Continue...
Server in ASP.NET-Core
Before you read
下面一些是来源.NET-Core官方文档中的一些内容,主要讲的是和Server 相关的一些内容,包括Kestrel 以及 ANCM . 对于理解.NET-Core 中的某些方面对我比较有帮助的,整理如下。基本是英文的,不难理解,就不翻译了。
ASP.NET Core Module
What ASP.NET Core Module does
ANCM is a native IIS module that hooks into the IIS pipeline and redirects traffic to the backend ASP.NET Core application.

Requests come in from the Web and hit the kernel mode Http.Sys driver which routes them into IIS on the primary port (80) or SSL port (443). ANCM forwards the requests to the ASP.NET Core application on the HTTP port configured for the application, which is not port 80/443.
Kestrel listens for traffic coming from ANCM. ANCM specifies the port via environment variable at startup, and the UseIISIntegration method configures the server to listen on http://localhost:{port}. There are additional checks to reject requests not from ANCM. (ANCM does not support HTTPS forwarding, so requests are forwarded over HTTP even if received by IIS over HTTPS.)
Kestrel picks up requests from ANCM and pushes them into the ASP.NET Core middleware pipeline, which then handles them and passes them on as HttpContext instances to application logic. The application's responses are then passed back to IIS, which pushes them back out to the HTTP client that initiated the requests.
ANCM port binding overrides other port bindings
ANCM generates a dynamic port to assign to the back-end process. The UseIISIntegration method picks up this dynamic port and configures Kestrel to listen on http://locahost:{dynamicPort}/. This overrides other URL configurations, such as calls to UseUrls or Kestrel's Listen API Therefore, you don't need to call UseUrls or Kestrel's Listen API when you use ANCM. If you do call UseUrls or Listen, Kestrel listens on the port you specify when you run the app without IIS.
Kestrel
When to use Kestrel with a reverse proxy


A scenario that requires a reverse proxy is when you have multiple applications that share the same IP and port running on a single server. That doesn't work with Kestrel directly because Kestrel doesn't support sharing the same IP and port between multiple processes. When you configure Kestrel to listen on a port, it handles all traffic for that port regardless of host header. A reverse proxy that can share ports must then forward to Kestrel on a unique IP and port.
PS: (About Host-Header) For example, the host header name for the URL http://www.cnblogs.com is www.cnblogs.com.
UseUrls limitations
You can configure endpoints by calling the UseUrls method or using the urls command-line argument or the ASPNETCORE_URLS environment variable. These methods are useful if you want your code to work with servers other than Kestrel. However, be aware of these limitations:
- You can't use SSL with these methods.
- If you use both the
Listenmethod andUseUrls, theListenendpoints override theUseUrlsendpoints.
URL prefixes
Only HTTP URL prefixes are valid; Kestrel does not support SSL when you configure URL bindings by using UseUrls.
- IPv4 address with port number
http://65.55.39.10:80/
0.0.0.0 is a special case that binds to all IPv4 addresses.
- IPv6 address with port number
http://[0:0:0:0:0:ffff:4137:270a]:80/
[::] is the IPv6 equivalent of IPv4 0.0.0.0.
- Host name with port number
http://contoso.com:80/ http://*:80/
Host names, *, and+, are not special. Anything that is not a recognized IP address or localhost will bind to all IPv4 and IPv6 IPs. If you need to bind different host names to different ASP.NET Core applications on the same port, use HttpSys or a reverse proxy server such as IIS, Nginx, or Apache.
Localhostname with port number or loopback IP with port number
http://localhost:5000/ http://127.0.0.1:5000/ http://[::1]:5000/
When localhost is specified, Kestrel tries to bind to both IPv4 and IPv6 loopback interfaces. If the requested port is in use by another service on either loopback interface, Kestrel fails to start. If either loopback interface is unavailable for any other reason (most commonly because IPv6 is not supported), Kestrel logs a warning.
Question Linked
Link Reference
- https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/servers/kestrel?tabs=aspnetcore2x
- https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/hosting?tabs=aspnetcore2x
- PS: Kestrel is a cross-platform HTTP server based on libuv, a cross-platform asynchronous I/O library.
Server in ASP.NET-Core的更多相关文章
- ASP.NET Core真实管道详解[2]:Server是如何完成针对请求的监听、接收与响应的【上】
Server是ASP .NET Core管道的第一个节点,负责完整请求的监听和接收,最终对请求的响应同样也由它完成.Server是我们对所有实现了IServer接口的所有类型以及对应对象的统称,如下面 ...
- Kestrel web server implementation in ASP.NET Core
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?tabs=aspnetcore1x&view ...
- .NET Core RC2发布在即,我们试着用记事本编写一个ASP.NET Core RC2 MVC程序
在.NET Core 1.0.0 RC2即将正式发布之际,我也应应景,针对RC2 Preview版本编写一个史上最简单的MVC应用.由于VS 2015目前尚不支持,VS Code的智能感知尚欠火候,所 ...
- ASP.NET Core WebListener 服务器
原文地址:WebListener server for ASP.NET Core By Tom Dykstra, Chris Ross WebListener是一个只能运行在Windows上的ASP. ...
- ASP.NET Core的Kestrel服务器
原文地址----Kestrel server for ASP.NET Core By Tom Dykstra, Chris Ross, and Stephen Halter Kestrel是一个基于l ...
- [转]ASP.NET Core 1 Deploy to IIS
本文转自: http://webmodelling.com/webbits/aspnet/aspnet-deploy-iis.aspx 15 Sep 2016. This tutorial will ...
- Professional C# 6 and .NET Core 1.0 - 40 ASP.NET Core
本文内容为转载,重新排版以供学习研究.如有侵权,请联系作者删除. 转载请注明本文出处:Professional C# 6 and .NET Core 1.0 - 40 ASP.NET Core --- ...
- ASP.NET Core:CMD命令行+记事本 创建Console程序和Web Application
今天看了Scott关于ASP.NET Core的介绍视频,发现用命令行一步一步新建项目.添加Package.Restore.Build.Run 执行的实现方式,更让容易让我们了解.NET Core的运 ...
- ASP.NET Core 认证与授权[4]:JwtBearer认证
在现代Web应用程序中,通常会使用Web, WebApp, NativeApp等多种呈现方式,而后端也由以前的Razor渲染HTML,转变为Stateless的RESTFulAPI,因此,我们需要一种 ...
- ASP.NET Core入门
一.搭建开发环境 在Windows平台下,开发.NET Core 程序需要安装如下内容: 1. .NET Core runtime 2. Visual Studio 2015 with Update ...
随机推荐
- 基于spring mvc的图片验证码实现
本文实现基于spring mvc的图片验证码,分后台代码和前端页面的展现以及验证码的验证. 首看后台实现代码: @RequestMapping({"authCode"}) publ ...
- 美国总统大选,黑客组织“匿名者”(Anonymous)也来凑热闹
美国总统大选,黑客组织"匿名者"(Anonymous)也来凑热闹 黑客组织"匿名者"向美国总统共和党候选人唐纳德•特朗普宣战,发誓将从4月1日开始向其发动大规模 ...
- spring基于注解进行注入(个人记录)
spring的Bean基于注解进行配置,再结合自动装配属性,也就DI,其实说白了就相当于初始化的时候给对象赋初值. 配置文件的过程有些麻烦,记录一下. 基于注解进行配置: 1.在application ...
- sort与qsort的用法,建议使用sort
做ACM题的时候,排序是一种经常要用到的操作.如果每次都自己写个冒泡之类的O(n^2)排序,不但程序容易超时,而且浪费宝贵的比赛时间,还很有可能写错.STL里面有个sort函数,可以直接对数组排序,复 ...
- python进阶学习(一)
同样是<python基础教程(第二版)>的内容,只是后面内容学起来,相比前面会比较有趣,也更加实用,所以,将"基础"改为"进阶". python 电 ...
- python基础教程(一)
之所以选择py交易有以下几点:1.python是胶水语言(跨平台),2.python无所不能(除了底层),3.python编写方便(notepad++等文本编辑器就能搞事情),4.渗透方面很多脚本都是 ...
- NCS8801S芯片RGB/LVDS转EDP功能简介
NCS8801S RGB/LVDS-to-eDP Converter (1/2/4-lane eDP) Features --Embedded-DisplayPort (eDP) Output 1/2 ...
- keepalive集群工作原理及应用
author:JevonWei 版权声明:原创作品 集群工作原理 一.集群基础 1.系统的扩展方式 scale up向上扩展:提高单台服务器的性能 scale out向外扩展:多台服务器联合起来满足同 ...
- 《物联网框架ServerSuperIO教程》- 22.动态数据接口增加缓存,提高数据输出到OPCServer和(实时)数据库的效率
22.1 概述及要解决的问题 设备驱动有DeviceDynamic接口,可以继承并增加新的实时数据属性,每次通讯完成后更新这些属性数据.原来是通过DeviceDynamic接口实体类反射的方式获 ...
- MySQL(七)MySQL常用函数
前言 上一篇给大家介绍了,MySQL常用的操作符其实已经是非常的详细了,现在给大家分享的是MySQL的常用函数.希望对我和对大家都有帮助. 一.字符串函数 1.1.LOWER.lcase(string ...