惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - ZHK的博客

在IIS Express中配置和启动web site 在File Explorer的当前路径上直接打开VS Code windows 下运行angualr/material2 项目 vs2017中生成.Net Standard Libarary的Nuget Package 使用nginx 的反向代理 给 kibana加上basic的身份认证 Hyper-V 虚拟网络设置 docker for windows & dotnet core app 使用performance monitor 查看 每一个cpu core的cpu time Ubuntu安装Python2.7,nodejs,Redis Ubuntu 16 安装ElasticSearch Ubuntu 16 安装JDK1.8 Ubuntu 14 安装 .Net Core AngularJS2 + ASP.NET MVC项目 Visual Studio Code 调试 nodeJS 固定Table的头部和左边的列-在Knockout Js使用场景下 Jquery UI - DatePicker 在Dialog中无法自动隐藏的解决思路 Visual Studio Code + live-server编辑和浏览HTML网页 ABP源码分析四十七:ABP中的异常处理 ABP源码分析四十六:ABP ZERO中的Ldap模块
基于空项目模板创建使用Owin来host的WebApi项目
ZHK的博客 · 2016-06-26 · via 博客园 - ZHK的博客

首先创建一个空的web项目,如下图所示:

项目创建成功以后,安装下面三个package.

Install-Package Microsoft.AspNet.WebApi -Version 5.2.2
Install-Package Microsoft.AspNet.WebApi.Owin -Version 5.2.2
Install-Package Microsoft.Owin.Host.SystemWeb -Version 3.0.0

创建Owin Startup 类

 1 using System;
 2 using System.Threading.Tasks;
 3 using Microsoft.Owin;
 4 using Owin;
 5 using System.Web.Http;
 6 
 7 [assembly: OwinStartup(typeof(FirstOwinWebApi.Startup))]
 8 
 9 namespace FirstOwinWebApi
10 {
11     public class Startup
12     {
13         public void Configuration(IAppBuilder app)
14         {
15             HttpConfiguration config = new HttpConfiguration();
16 
17             // Web API routes
18             config.MapHttpAttributeRoutes();
19 
20             //WebApiConfig.Register(config);
21 
22             app.UseWebApi(config);
23         }
24     }
25 }


创建API Controller.

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Net;
 5 using System.Net.Http;
 6 using System.Web.Http;
 7 
 8 namespace FirstOwinWebApi.Controllers
 9 {
10     [RoutePrefix("api/HelloWorld")]
11     public class HelloWorldController : ApiController
12     {
13         [Route("")]
14         public IHttpActionResult Post()
15         {
16 
17             return Ok<string>("Hello World");
18 
19         }
20 
21     }
22 }

F5运行,使用Postman访问Api

其他一些Owin中间件包:

Install-Package Microsoft.AspNet.WebApi -Version 5.2.2

Install-Package Microsoft.AspNet.WebApi.Owin -Version 5.2.2

Install-Package Microsoft.Owin.Host.SystemWeb -Version 3.0.0

Install-Package Microsoft.Owin.Cors -Version 3.0.0

Install-Package Microsoft.Owin.Security.OAuth -Version 3.0.0

Install-Package Microsoft.Owin.Security.Jwt -Version 3.0.0

Install-Package System.IdentityModel.Tokens.Jwt -Version 4.0.0

Install-Package Thinktecture.IdentityModel.Core Version 1.2.0

Install-Package Microsoft.AspNet.Identity.Owin -Version 2.0.1

Install-Package Microsoft.AspNet.Identity.EntityFramework -Version 2.0.1