.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.使用场合 ...
随机推荐
- WebService核心文件【server-config.wsdd】详解及调用示例
WebService核心文件[server-config.wsdd]详解及调用示例 作者:Vashon 一.准备工作 导入需要的jar包: 二.配置web.xml 在web工程的web.xml中添加如 ...
- CentOS6.5(Python-2.7.12)安装Pip
1.安装setuptools(下载链接可从https://pypi.python.org/pypi/setuptools#code-of-conduct寻找) #Download setuptools ...
- Memcache入门
说来惭愧,第一次听说Memcache是在大约在6个月前.作为一个搞J2EE开发的,工作一年多了,都没听说过Memcache实在是惭愧. 当时是换了新工作,第一个任务是开发一个报表系统供公司内部使用.为 ...
- [瞎JB写] C++多态
似乎只能通过引用或者指针进行动态多态...蛋疼的语法 #include <iostream> #include <vector> #include <memory> ...
- uva 10562 undraw the trees(烂题) ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABB4AAAM9CAYAAAA7ObAlAAAgAElEQVR4nOyd25GsupKGywVswAV8wA ...
- 《TCP/IP详解 卷一》读书笔记-----TCP数据流
1.Delayed Acknowledgements:TCP通常不会在收到数据之后立即返回一个ACK,而是会有一个延时,希望能ACK报文段中带上一些数据,通常这个延时为200ms 2.Nagle Al ...
- HDU 5047 推公式+别样输出
题意:给n个‘M'形,问最多能把平面分成多少区域 解法:推公式 : f(n) = 4n(4n+1)/2 - 9n + 1 = (8n+1)(n-1)+2 前面部分有可能超long long,所以要转化 ...
- 2014 UESTC 暑前集训队内赛(2) 部分解题报告
B.Cuckoo for Hashing 模拟题. 代码: #include <iostream> #include <cstdio> #include <cstring ...
- 关于jQuery的一些实用代码
(1)修改默认编码:(将默认的utf-8,修改为GB2312) $.ajaxSetup({ ajaxSettings:{contentType:"application/x-www-from ...
- LYK 快跑!(LYK别打我-)(话说LYK是谁)
LYK 快跑!(run) Time Limit:5000ms Memory Limit:64MB 题目描述 LYK 陷进了一个迷宫! 这个迷宫是网格图形状的. LYK 一开始在(1,1)位置, 出口在 ...