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
OWIN 中 K Commands 与 OwinHost.exe 相等吗?的更多相关文章
- OWIN 中 K Commands(OwinHost.exe)与 Microsoft.AspNet.Hosting 的角色问题
问题详情:K Commands(OwinHost.exe)是不是 OWIN 中的 Host 角色?如果是,那 Microsoft.AspNet.Hosting 对应的是 OWIN 中的哪个角色? OW ...
- 深入理解 OWIN 中的 Host 和 Server
The Open Web Interface for .NET (OWIN),注意单词为大写,之前好像都写成了 Owin,但用于项目的时候,可以写成:Microsoft.Owin.*. OWIN 体系 ...
- OwinHost.exe用法
简介 OwinHost.exe是微软提供的自宿主host,如果自己不想写owin的host,可以用这个. 官方对OwinHost的描述为:Provides a stand-alone executab ...
- [转]C#中调用资源管理器(Explorer.exe)打开指定文件夹 + 并选中指定文件 + 调用(系统默认的播放类)软件(如WMP)打开(播放歌曲等)文件
原文:http://www.crifan.com/csharp_call_explorer_to_open_destinate_folder_and_select_specific_file/ C#中 ...
- visual 2008中error PRJ0003 : 生成 cmd.exe 时出错
visual 2008中error PRJ0003 : 生成 cmd.exe 时出错”, 和vs2008 sp1没关系 解决方案:工具—>选项—>项目和解决方案—>VC++目录, ...
- 在InstallShield中发布单一的Setup.exe文件
原文:在InstallShield中发布单一的Setup.exe文件 InstallShield默认的Release模式下,生成了一个setup.exe文件,一个msi文件,以及一些其它的杂项文件. ...
- 机器学习中 K近邻法(knn)与k-means的区别
简介 K近邻法(knn)是一种基本的分类与回归方法.k-means是一种简单而有效的聚类方法.虽然两者用途不同.解决的问题不同,但是在算法上有很多相似性,于是将二者放在一起,这样能够更好地对比二者的异 ...
- Opencv中K均值算法(K-Means)及其在图像分割中的应用
K均值(K-Means)算法是一种无监督的聚类学习算法,他尝试找到样本数据的自然类别,分类是K由用户自己定义,K均值在不需要任何其他先验知识的情况下,依据算法的迭代规则,把样本划分为K类.K均值是最常 ...
- IDED中配置SVN没有svn.exe解决办法
首先在idea中配置svn时
随机推荐
- 【Telerik】弹出对话框RadWindow,确认删除信息
要做一个删除功能,但是删除前正常都要弹出对话框确认一下是否删除信息,防止误删信息.
- 关于AlertDialog.Builder(Context context)中所应传入的context
错误报告: 10-20 14:34:46.565: E/AndroidRuntime(23098): FATAL EXCEPTION: main10-20 14:34:46.565: E/Androi ...
- Python之路第一课Day6--随堂笔记(面向对象 )
本节内容: 1. 面向对象编程介绍 2. 为什么要用面向对象进行开发? 3. 面向对象的特性:封装.继承.多态 4. 类.方法 一.面向过程 VS 面向对象 1. 编程范式 编程是 程序 员 用 ...
- 原来scanf读入字符串还能这样..
(本文针对于NOIP Day1 玩具迷题) (这是弱鸡写的)(字符串用char二维,本质一样的) 在NOIP成功AC了这道题,结果OJ上被string卡了时间,没办法只能用scanf了.....百度看 ...
- .Net程序员之不学Java做安卓开发:奇怪的Java语法
1.final关键字:用以修饰类时,表示类不可以被继承,指向基本数据类型或者引用类型时,该类只可以在声明的时候初始化 2.@Override 类似C# 中override关键字,表示对父类的重写.网上 ...
- java并发编程(十六)happen-before规则
转载请注明出处:http://blog.csdn.net/ns_code/article/details/17348313 happen-before规则介绍 Java语言中有一个"先行发生 ...
- C\C++ 生成各位数不相等的随机数
最近想写一个1A2B的小游戏来练习一下,结果在第一步生成随机数的时候就遇到了一点点问题. 游戏初始化时需要先生成一个四位随机数,且各位各不相等.于是最开始的思路是生成一个整数数组,只需要判断生成的随机 ...
- vector删除元素浅析
<<effectSTL>>书中提到erase-remove方法 即c.rease(remove(c.begin(),c.end(),1963),c.end()) 关于remo ...
- 【实战Java高并发程序设计 7】让线程之间互相帮助--SynchronousQueue的实现
[实战Java高并发程序设计 1]Java中的指针:Unsafe类 [实战Java高并发程序设计 2]无锁的对象引用:AtomicReference [实战Java高并发程序设计 3]带有时间戳的对象 ...
- 我的第一段jQuery代码
说起 jQuery,很多人可能觉得,不算什么,就是个js类库.而,对于我,下面这几行代码,是一个新的开始. 多年来,我一直在使用MooTools ,他面向对象,写起来结构清晰分明,都是在原生js的基础 ...