integration asp.net web api with autofac and owin
There is an example project showing Web API in conjunction with OWIN self hosting
https://github.com/autofac/Examples/tree/master/src/WebApiExample.OwinSelfHost
https://github.com/autofac/Examples/blob/master/src/WebApiExample.OwinSelfHost/Startup.cs
Owin
https://autofaccn.readthedocs.io/en/latest/integration/owin.html
OWIN (Open Web Interface for .NET) is a simpler model for composing web-based applications without tying the application to the web server. To do this, a concept of “middleware” is used to create a pipeline through which requests travel.
Due to the differences in the way OWIN handles the application pipeline (detecting when a request starts/ends, etc.) integrating Autofac into an OWIN application is slightly different than the way it gets integrated into more “standard” ASP.NET apps. You can read about OWIN and how it works on this overview.
The important thing to remember is that order of OWIN middleware registration matters. Middleware gets processed in order of registration, like a chain, so you need to register foundational things (like Autofac middleware) first.
Quick Start
To take advantage of Autofac in your OWIN pipeline:
- Reference the
Autofac.Owinpackage from NuGet. - Build your Autofac container.
- Register the Autofac middleware with OWIN and pass it the container.
Web api integration with owin
https://autofaccn.readthedocs.io/en/latest/integration/webapi.html#owin-integration
If you are using Web API as part of an OWIN application, you need to:
- Do all the stuff for standard Web API integration - register controllers, set the dependency resolver, etc.
- Set up your app with the base Autofac OWIN integration.
- Add a reference to the Autofac.WebApi2.Owin NuGet package.
- In your application startup class, register the Autofac Web API middleware after registering the base Autofac middleware.
A common error in OWIN integration is use of the GlobalConfiguration.Configuration.
In OWIN you create the configuration from scratch.
You should not reference GlobalConfiguration.Configuration anywhere when using the OWIN integration.
integration asp.net web api with autofac and owin的更多相关文章
- (转)【ASP.NET Web API】Authentication with OWIN
概述 本文说明了如何使用 OWIN 来实现 ASP.NET Web API 的验证功能,以及在客户端与服务器的交互过程中,避免重复提交用户名和密码的机制. 客户端可以分为两类: JavaScript: ...
- 在ASP.NET Web API 2中使用Owin OAuth 刷新令牌(示例代码)
在上篇文章介绍了Web Api中使用令牌进行授权的后端实现方法,基于WebApi2和OWIN OAuth实现了获取access token,使用token访问需授权的资源信息.本文将介绍在Web Ap ...
- 在ASP.NET Web API 2中使用Owin基于Token令牌的身份验证
基于令牌的身份验证 基于令牌的身份验证主要区别于以前常用的常用的基于cookie的身份验证,基于cookie的身份验证在B/S架构中使用比较多,但是在Web Api中因其特殊性,基于cookie的身份 ...
- ASP.NET Web API 安全筛选器
原文:https://msdn.microsoft.com/zh-cn/magazine/dn781361.aspx 身份验证和授权是应用程序安全的基础.身份验证通过验证提供的凭据来确定用户身份,而授 ...
- ASP.NET Web API安全认证
http://www.cnblogs.com/codeon/p/6123863.html http://open.taobao.com/docs/doc.htm?spm=a219a.7629140.0 ...
- [转] JSON Web Token in ASP.NET Web API 2 using Owin
本文转自:http://bitoftech.net/2014/10/27/json-web-token-asp-net-web-api-2-jwt-owin-authorization-server/ ...
- JSON Web Token in ASP.NET Web API 2 using Owin
In the previous post Decouple OWIN Authorization Server from Resource Server we saw how we can separ ...
- Autofac ASP.NET Web API (Beta) Integration
With the beta release of ASP.NET MVC 4 and the ASP.NET Web API being released a few weeks ago, I dec ...
- 使用Autofac在ASP.NET Web API上实现依赖注入
在ASP.NET Web API里使用Autofac 1.通过NuGet安装Autofac.WebApi(当时安装的是Autofac 3.1.0) PM > Install-Package Au ...
随机推荐
- vue-router路由懒加载
正常配置 import Vue from 'vue' import Router from 'vue-router' import Login from '@/components/pages/log ...
- Python 类型和对象(转)
译文:http://wiki.woodpecker.org.cn/moin/PyTypesAndObjects 原文:http://www.cafepy.com/article/python_attr ...
- Python慢,为啥还有大公司用?
PyCon 是全世界最大的以 Python 编程语言 为主题的技术大会,大会由 Python 社区组织,每年举办一次.在 Python 2017 上,Instagram 的工程师们带来了一个有关 Py ...
- redis_cluster部署过程
Redis集群1.多个redis节点网络互联,数据共享2.所有的节点都是一主一从(可以是多个从),其中从不提供服务3.不支持同时处理多个键(如mset/mget),因为redis需要把键均匀分布在各个 ...
- 汇编的WEAK关键字
一般来说,这个关键字使用在IMPORT和EXPORT这两个声明段. ////////////////////////////////////////////////////////////////// ...
- C的指针疑惑:C和指针6(指针)
NULL: 对所有指针变量进行显式的初始化是种好事:(1)如果你知道指针将被初始化为什么地址,就直接初始化该地址, (2)否则把它初始化位NULL. 注意:假定变量a存储于位置100. × = 看上去 ...
- 子集和问题(应用--换零钱)POJ2229:Sumsets
我一直在纠结换零钱这一类型的题目,今天好好絮叨一下,可以说他是背包的应用,也可以说他是单纯的dp.暂且称他为dp吧. 先上一道模板题目. sdut2777: 小P的故事——神奇的换零钱 题目描述 已知 ...
- 6 TensorFlow实现cnn识别手写数字
------------------------------------ 写在开头:此文参照莫烦python教程(墙裂推荐!!!) ---------------------------------- ...
- HALCON里面的一维测量。
第一步:将图片导入, 拿到图片的名字 和窗口的句柄 第二步:创建一个测量区域.这个测量区域是一个矩形,假设他的名字叫A gen_measure_rectangle2 (TmpCtrl_Row,//输入 ...
- jQuery Ajax使用总结
一.概述 jQuery对Ajax操作进行了封装,在jQuery中$.ajax()是属于最底层的方法,第2层是load().$.get()和$.post()方法,第三层是$.getScript()和$. ...