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

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

Hosting--------------------------------------------------------------------------Setting up a Host :using Microsoft.AspNetCore.Hosting;    public class Program    {        public static void Main(string[] args)        {            var host = new WebHostBuilder()                .UseKestrel()                .UseContentRoot(Directory.GetCurrentDirectory())                .UseIISIntegration()                .UseStartup
() .Build(); host.Run(); } }var host = new WebHostBuilder() .UseKestrel() .Configure(app => { app.Run(async (context) => await context.Response.WriteAsync("Hi!")); }) .Build();host.Run();--------------------------------------------------------------------------Configuring a Host:new WebHostBuilder() .UseSetting("applicationName", "MyApp")Host Configuration ValuesApplication Name stringKey: applicationName. This configuration setting specifies the value that will be returned from IHostingEnvironment.ApplicationName.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Capture Startup Errors boolKey: captureStartupErrors. Defaults to false. When false, errors during startup result in the host exiting. When true, the host will capture any exceptions from the Startup class and attempt to start the server. It will display an error page (generic, or detailed, based on the Detailed Errors setting, below) for every request. Set using the CaptureStartupErrors method.new WebHostBuilder() .CaptureStartupErrors(true)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Content Root stringKey: contentRoot. Defaults to the folder where the application assembly resides (for Kestrel; IIS will use the web project root by default). This setting determines where ASP.NET Core will begin searching for content files, such as MVC Views. Also used as the base path for the Web Root setting. Set using the UseContentRoot method. Path must exist, or host will fail to start.new WebHostBuilder() .UseContentRoot("c:\\mywebsite")++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Detailed Errors boolKey: detailedErrors. Defaults to false. When true (or when Environment is set to “Development”), the app will display details of startup exceptions, instead of just a generic error page. Set using UseSetting.new WebHostBuilder() .UseSetting("detailedErrors", "true")++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Environment stringKey: environment. Defaults to “Production”. May be set to any value. Framework-defined values include “Development”, “Staging”, and “Production”. Values are not case sensitive. See Working with Multiple Environments. Set using the UseEnvironment method.new WebHostBuilder() .UseEnvironment("Development")++++++++++++++++++++++++++++++++++++++++++++++++++Server URLs stringnew WebHostBuilder() .UseUrls("http://*:5000;http://localhost:5001;https://hostname:5002")++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Startup Assembly stringnew WebHostBuilder() .UseStartup("StartupAssemblyName")++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Web Root stringnew WebHostBuilder() .UseWebRoot("public")public static void Main(string[] args){ var config = new ConfigurationBuilder() .AddCommandLine(args) .AddJsonFile("hosting.json", optional: true) .Build(); var host = new WebHostBuilder() .UseConfiguration(config) .UseKestrel() .Configure(app => { app.Run(async (context) => await context.Response.WriteAsync("Hi!")); }) .Build(); host.Run();}+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++dotnet run --urls "http://*:5000"var urls = new List
() { "http://*:5000", "http://localhost:5001" };var host = new WebHostBuilder() .UseKestrel() .UseStartup
() .Start(urls.ToArray());using (host){ Console.ReadLine();}

 

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

你可能感兴趣的文章
Web API 持续集成:PostMan+Newman+Jenkins(图文讲解)
查看>>
证书生成加密码解密
查看>>
弹窗查看内容时 内容滚动区域设置为body区
查看>>
Windows Azure Platform Introduction (6) Windows Azure应用程序运行环境
查看>>
Windows Azure VM Role (3) 在VHD中安装Windows Server 2008 R2
查看>>
Windows 8 Platform (三) Windows 8 Developer Preview
查看>>
根据条件用一个表的字段,去更新另一个表的字段
查看>>
thinkphp模板中使用自定义函数
查看>>
TP复习3
查看>>
(Delphi) Using the Disk Cache 使用磁盘缓存
查看>>
用Feature的方式删除SharePoint2010的Page中重复的WebPart
查看>>
递归算法学习系列之三(快速排序)
查看>>
从TdataSet生成OleVariant
查看>>
预告和目录: Wayne Game Solution 0.1 网络游戏大厅 从最基础开始
查看>>
xBIM WeXplorer xViewer的导航,相机、剖切、隐藏 等操作
查看>>
(转)预编译头文件
查看>>
艾伟_转载:浅析IHttpModule和IHttpHandler
查看>>
百万级访问量网站的技术准备工作
查看>>
Gnome Tweak Tool 3.0.5发布
查看>>
杭州鼎家被曝破产:长租公寓过度金融化酿恶果
查看>>