.NET跨平台之OWEN中 过滤器的使用
.NET中依赖IIS,通俗的说就是依赖IIS的程序集,导致我们的.NET项目就算是MONO到TOMCAT上,也无法使用,所以OWEN横空出世,OWEN定义了一套接口,接口定义了做.NET项目要实现的一些接口,OWEN本身通过这些接口获取到我们项目中的Request/Response,拿着这些去和Server(IIS\APCHE\TOMCAT...)通信.
回到正题,我们知道在MVC中,可以有
public override void OnActionExecuted(ActionExecutedContext filterContext)
public override void OnAuthorization(AuthorizationContext filterContext) ... OWEN中就是
namespace Owin
{
/// <summary>
/// An ordered list of known Asp.Net integrated pipeline stages. More details on the ASP.NET integrated pipeline can be found at http://msdn.microsoft.com/en-us/library/system.web.httpapplication.aspx
/// </summary>
public enum PipelineStage
{
/// <summary>
/// Corresponds to the AuthenticateRequest stage of the ASP.NET integrated pipeline.
/// </summary>
Authenticate, /// <summary>
/// Corresponds to the PostAuthenticateRequest stage of the ASP.NET integrated pipeline.
/// </summary>
PostAuthenticate, /// <summary>
/// Corresponds to the AuthorizeRequest stage of the ASP.NET integrated pipeline.
/// </summary>
Authorize, /// <summary>
/// Corresponds to the PostAuthorizeRequest stage of the ASP.NET integrated pipeline.
/// </summary>
PostAuthorize, /// <summary>
/// Corresponds to the ResolveRequestCache stage of the ASP.NET integrated pipeline.
/// </summary>
ResolveCache, /// <summary>
/// Corresponds to the PostResolveRequestCache stage of the ASP.NET integrated pipeline.
/// </summary>
PostResolveCache, /// <summary>
/// Corresponds to the MapRequestHandler stage of the ASP.NET integrated pipeline.
/// </summary>
MapHandler, /// <summary>
/// Corresponds to the PostMapRequestHandler stage of the ASP.NET integrated pipeline.
/// </summary>
PostMapHandler, /// <summary>
/// Corresponds to the AcquireRequestState stage of the ASP.NET integrated pipeline.
/// </summary>
AcquireState, /// <summary>
/// Corresponds to the PostAcquireRequestState stage of the ASP.NET integrated pipeline.
/// </summary>
PostAcquireState, /// <summary>
/// Corresponds to the PreRequestHandlerExecute stage of the ASP.NET integrated pipeline.
/// </summary>
PreHandlerExecute,
}
}
差不多够用了。
代码会这么写:
首先要确定拦截到这个过滤器之后,要干啥
app.Use(typeof(OAuthBearerAuthenticationMiddleware), app, options);
OAuthBearerAuthenticationMiddleware是时间了OWEN接口的自定义中间件,授权用
然后定义中间件在哪个过滤器注入
object obj;
if (app.Properties.TryGetValue("integratedpipeline.StageMarker", out obj))
{
var addMarker = (Action<IAppBuilder, string>)obj;
addMarker(app, PipelineStage.Authenticate.ToString());
}
.NET跨平台之OWEN中 过滤器的使用的更多相关文章
- AspNet MVC3中过滤器 + 实例
AspNet MVC3中过滤器 + 实例 过滤器在请求管线注入额外的逻辑,提供简单优雅的方法实现横切点关注(AOP),例如日志,授权,缓存等应用.通过AOP可以减少在实际的业务逻辑中参杂过多非直接业务 ...
- flask中过滤器的使用
过滤器 过滤器的本质就是函数.有时候我们不仅仅只是需要输出变量的值,我们还需要修改变量的显示,甚至格式化.运算等等,而在模板中是不能直接调用 Python 中的某些方法,那么这就用到了过滤器. 使用方 ...
- JSP中过滤器的设置
JSP中过滤器的设置 package com.filter; import java.io.IOException; import java.net.URLDecoder; import java.u ...
- SpringBoot图文教程6—SpringBoot中过滤器的使用
有天上飞的概念,就要有落地的实现 概念十遍不如代码一遍,朋友,希望你把文中所有的代码案例都敲一遍 先赞后看,养成习惯 SpringBoot 图文系列教程技术大纲 鹿老师的Java笔记 SpringBo ...
- Struts2中过滤器和拦截器的区别
拦截器和过滤器的区别: 1.拦截器是基于java的反射机制的,而过滤器是基于函数回调 2.过滤器依赖与servlet容器,而拦截器不依赖与servlet容器 3.拦截器只能对action请求起作用,而 ...
- Java Web 中 过滤器与拦截器的区别
过滤器,是在java web中,你传入的request,response提前过滤掉一些信息,或者提前设置一些参数,然后再传入servlet或者struts的 action进行业务逻辑,比如过滤掉非法u ...
- SpringBoot中过滤器、监听器以及拦截器
属于javax.servlet所提供的Api 拦截器原理 简单来讲是通过动态代理实现,被访问的目标方法通过代理类(方法)来执行,这样我们就可以在真正要执行的方法执行前.后做一些处理: 通过拦截器这种方 ...
- 【过滤器】web中过滤器的使用与乱码问题解决
一.过滤器Filter 1.filter的简介 filter是对客户端访问资源的过滤,符合条件放行,不符合条件不放行,并且可以对目 标资源访问前后进行逻辑处理 2.快速入门 步骤: 1)编写一个过 ...
- JAVAWEB开发中过滤器的概述及使用
1.什么是过滤器? 过滤器是向WEB应用程序的请求和响应添加功能的WEB服务组件 2.过滤器的作用 1)可以统一的集中处理请求和响应 2)可以实现对请求数据的过滤 3.过滤器的工作方式 4.使用场合 ...
随机推荐
- linux把EDT时间修改为CST格式
初始时间:2012年 09月 14日 星期五 18:15:33 EDT [root@test ~]# mv /etc/localtime /etc/localtime.bak [root@test ~ ...
- Effective Java 40 Design method signatures carefully
Principle Choose method names carefully. Don't go overboard in providing convenience methods. Avoid ...
- mongo学习笔记(五):分片
分片 人脸: 代表客户端,客户端肯定说,你数据库分片不分片跟我没关系,我叫你干啥就干啥,没什么好商量的. mongos: 首先我们要了解”片键“的概念,也就是说拆分集合的依据是什么?按照 ...
- proxool详细配置
proxool详细配置 博客分类: Java 配置管理SQLServletprototypeXML proxool一个数据库连接池框架,提供了对你选择的其它类型的驱动程序的连接池封装.可以非常简单的 ...
- POI教程之第一讲:创建新工作簿, Sheet 页,创建单元格
第一讲 Poi 简介 Apache POI 是Apache 软件基金会的开放源码函数库,Poi提供API给java程序对Microsoft Office格式档案读和写的功能. 1.创建新工作簿,并给工 ...
- 嵌入式开发板iTOP4412学习开发板
网站:http://www.topeetboard.com 淘宝:https://item.taobao.com/item.htm?_u=okcahs0f42a&id=38712193806 ...
- Mongodb 主从复制与副本集实验
1.实验主从复制,并验证复制成功,抓图实验过程 Step1:创建相应的目录 Mkdir -p ./dbs/master Mkdir -p ./dbs/slave Step2:开启主服务 ./bin/ ...
- ubuntu apache2服务器配置
把django开发好的项目部署到apache2服务器. 记录我的配置过程. apache,django,mod_wsgi,python版本如下.不同版本大同小异. ii apache2 2.2.22- ...
- 【Android UI设计与开发】8.顶部标题栏(一)ActionBar 奥义·详解
一.ActionBar介绍 在Android 3.0中除了我们重点讲解的Fragment外,Action Bar也是一个非常重要的交互元素,Action Bar取代了传统的tittle bar和men ...
- 【Ext.Net学习笔记】05:Ext.Net GridPanel的用法(包含Filter、Sorter、Grouping、汇总(Summary)的用法)
GridPanel是用来显示数据的表格,与ASP.NET中的GridView类似. GridPanel用法 直接看代码: <ext:GridPanel runat="server&qu ...