博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DotNet 学习笔记 Servers
阅读量:6718 次
发布时间:2019-06-25

本文共 2951 字,大约阅读时间需要 9 分钟。

ServersASP.NET Core ships with two different HTTP servers:•Microsoft.AspNetCore.Server.Kestrel (AKA Kestrel, cross-platform)•Microsoft.AspNetCore.Server.WebListener (AKA WebListener, Windows-only, preview){  "webroot": "wwwroot",  "version": "1.0.0-*",  "dependencies": {    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final"  },  "commands": {    "run": "run server.urls=http://localhost:5003",    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000",    "weblistener": "Microsoft.AspNet.Hosting --server WebListener --server.urls http://localhost:5004"  },  "frameworks": {    "dnx451": { },using System;using System.Threading.Tasks;using Microsoft.AspNet.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.AspNet.Builder;using Microsoft.Extensions.Logging;using Microsoft.AspNet.Server.Kestrel;namespace ServersDemo{    ///     /// This demonstrates how the application can be launched in a console application.     /// Executing the "dnx run" command in the application folder will run this app.    ///     public class Program    {        private readonly IServiceProvider _serviceProvider;        public Program(IServiceProvider serviceProvider)        {            _serviceProvider = serviceProvider;        }        public Task
Main(string[] args) { //Add command line configuration source to read command line parameters. var builder = new ConfigurationBuilder(); builder.AddCommandLine(args); var config = builder.Build(); using (new WebHostBuilder(config) .UseServer("Microsoft.AspNet.Server.Kestrel") .Build() .Start()) { Console.WriteLine("Started the server.."); Console.WriteLine("Press any key to stop the server"); Console.ReadLine(); } return Task.FromResult(0); } }}------------------------------------------------------------------------------Programmatic configurationpublic void Configure(IApplicationBuilder app, IApplicationLifetime lifetime, ILoggerFactory loggerFactory){ var webListenerInfo = app.ServerFeatures.Get
(); if (webListenerInfo != null) { webListenerInfo.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.AllowAnonymous; } var serverAddress = app.ServerFeatures.Get
()?.Addresses.FirstOrDefault(); app.Run(async (context) => { var message = String.Format("Hello World from {0}", serverAddress); await context.Response.WriteAsync(message); });}"web": "Microsoft.AspNetCore.Hosting --server Microsoft.AspNetCore.Server.WebListener --server.urls http://localhost:5000"

 

转载于:https://www.cnblogs.com/ziranquliu/p/5884265.html

你可能感兴趣的文章
poj 1466 Girls and Boys (最大独立集)
查看>>
辛星与您使用CSS导航条
查看>>
统计一个文件中出现字符'a'的次数
查看>>
将Eclipse包括第一3正方形jar包裹Project Export并产生能够执行jar
查看>>
Google Pagespeed,自动压缩优化JS/CSS/Image
查看>>
Gentoo源码安装图解
查看>>
【转载】COM 组件设计与应用(三)——数据类型
查看>>
Python yield与实现
查看>>
购物车特效收集
查看>>
Access中一句查询代码实现Excel数据导入导出
查看>>
2015第49周二
查看>>
Sphinx/Coreseek 4.1的安装流程
查看>>
邮件服务器Postfix的管理 重启php-fpm
查看>>
Android Studio 项目代码全部消失--出现原因及解决方法
查看>>
SQL Server---存储过程
查看>>
MySQL Performance-Schema(二) 理论篇
查看>>
搭建SSH详细步骤及相关说明
查看>>
Android IOS WebRTC 音视频开发总结(五五)-- 音视频通讯中的抗丢包与带宽自适应原理...
查看>>
Libgdx: 将Texturepacker打包的PNG图片还原成一张一张的单个的
查看>>
再议Swift操作符重载
查看>>