国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

OWIN 中 K Commands 與 OwinHost.exe 相等嗎?

2019-11-17 01:58:38
字體:
來源:轉載
供稿:網友

OWIN 中 K Commands 與 OwinHost.exe 相等嗎?

  • OwinHost.exe: While some will want to write a custom PRocess to run Katana Web applications, many would prefer to simply launch a pre-built executable that can start a server and run their application. For this scenario, the Katana component suite includes OwinHost.exe. When run from within a project’s root directory, this executable will start a server (it uses the HttpListener server by default) and use conventions to find and run the user’s startup class. For more granular control, the executable provides a number of additional command line parameters.
  • K Commands: Whenever you want to run your app in command line using K* commands, you will use k run. The K command is your entry point to the runtime. To run an application you can use K run to build you can use K build, and all other commands that are about taking your application and running it.

K Commands 是 APS.NET 5 引出的,根據說明知道它是加載與啟動 OWIN 組件的一個命令,那 OwinHost.exe 是什么?它其實是之前 OWIN 的實現 Katana 項目中的一個東西,這個東西是什么?看一下源碼結構:

摘自 Program.cs 中的一段源代碼:

using System;using System.Collections.Generic;using System.Diagnostics.CodeAnalysis;using System.Globalization;using System.IO;using System.Linq;using System.Reflection;using Microsoft.Owin.Hosting;using Microsoft.Owin.Hosting.Services;using Microsoft.Owin.Hosting.Starter;using Microsoft.Owin.Hosting.Utilities;using OwinHost.Options;namespace OwinHost{    public static class Program    {        public static void RunServer(StartOptions options)        {            if (options == null)            {                return;            }            string boot;            if (!options.Settings.TryGetValue("boot", out boot)                || string.IsNullOrWhiteSpace(boot))            {                options.Settings["boot"] = "Domain";            }            ResolveAssembliesFromDirectory(                Path.Combine(Directory.GetCurrentDirectory(), "bin"));            WriteLine("Starting with " + GetDisplayUrl(options));            IServiceProvider services = ServicesFactory.Create();            var starter = services.GetService<IHostingStarter>();            IDisposable server = starter.Start(options);            WriteLine("Started successfully");            WriteLine("Press Enter to exit");            Console.ReadLine();            WriteLine("Terminating.");            server.Dispose();        }    }}

可以看到,它其實和 Microsoft.aspNet.Hosting/Program.cs 中的配置代碼很相似,但不相同,Microsoft.AspNet.Hosting 是 OWIN Host 的所有概念實現,而 OwinHost 只是一個控制臺啟動程序,用來加載所有的 OWIN 組件,但它不包含任何的實現,比如 Host 中的 Builder、Server、Startup 等一些操作,再看下面一張圖就明白了:

對,沒錯,OwinHost 依賴于 Microsoft.Owin.Hosting,OwinHost 中所有的 Host 操作都在 Microsoft.Owin.Hosting 中進行完成了,說白了,OwinHost 沒多少東西,就是一個開啟命令,和 Microsoft.AspNet.Hosting 完全不是一個概念問題,那 OwinHost 和 K Commands 相等嗎?其實也不相等,只是很類似,但這個類似點只是體現在加載 OWIN 組件的時候,OwinHost 的工作就是干這個的,并且只能干這個,而 K Commands 卻不僅僅如此,它還包含了其他的一些命令管理,比如“gen”、“ef”等。

其他相關資料:

  • What is the difference between using Owinhost.exe to run an OWIN web service or a Console App
  • Visual Studio 2013 Custom Web Servers and OwinHost.exe

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 上虞市| 苏尼特左旗| 吉林市| 灵璧县| 陆良县| 莱州市| 青川县| 双柏县| 平顺县| 连江县| 三门峡市| 秦皇岛市| 胶南市| 台前县| 禹城市| 威海市| 南陵县| 锡林浩特市| 鄂州市| 泸定县| 宜宾市| 三门峡市| 基隆市| 育儿| 上饶县| 平遥县| 绥棱县| 金门县| 宝丰县| 武平县| 虹口区| 开平市| 汕尾市| 海伦市| 仲巴县| 襄汾县| 霞浦县| 英山县| 莱阳市| 舞钢市| 丽水市|