ASP.NET Core中间件记录管道图和内置中间件

管道记录

下图显示了 ASP.NET Core MVC 和 Razor Pages 应用程序的完整请求处理管道

中间件组件在文件中添加的顺序Program.cs定义了请求时调用中间件组件的顺序以及响应的相反顺序。该顺序对于安全性、性能和功能至关重要。 

内置中间件记录

内置中间件
原文翻译
MiddlewareDescriptionOrder中间件描述命令
AuthenticationProvides authentication support.Before HttpContext.User is needed. Terminal for OAuth callbacks.验证提供身份验证支持。之前HttpContext.User是需要的。OAuth 回调终端。
AuthorizationProvides authorization support.Immediately after the Authentication Middleware.授权提供授权支持。紧接着身份验证中间件。
Cookie PolicyTracks consent from users for storing personal information and enforces minimum standards for cookie fields, such as secure and SameSite.Before middleware that issues cookies. Examples: Authentication, Session, MVC (TempData).Cookie 政策跟踪用户对存储个人信息的同意并强制执行 cookie 字段的最低标准,例如secureSameSite在发布 cookie 的中间件之前。示例:身份验证、会话、MVC(临时数据)。
CORSConfigures Cross-Origin Resource Sharing.Before components that use CORS. UseCors currently must go before UseResponseCaching due to this bug.跨域资源共享配置跨源资源共享。在使用 CORS 的组件之前。由于这个错误,UseCors目前必须先走。UseResponseCaching
DeveloperExceptionPageGenerates a page with error information that is intended for use only in the Development environment.Before components that generate errors. The project templates automatically register this middleware as the first middleware in the pipeline when the environment is Development.开发者异常页面生成一个包含错误信息的页面,该页面仅供在开发环境中使用。在产生错误的组件之前。当环境为开发时,项目模板会自动将此中间件注册为管道中的第一个中间件。
DiagnosticsSeveral separate middlewares that provide a developer exception page, exception handling, status code pages, and the default web page for new apps.Before components that generate errors. Terminal for exceptions or serving the default web page for new apps.诊断几个独立的中间件,为新应用程序提供开发人员异常页面、异常处理、状态代码页面和默认网页。在产生错误的组件之前。用于例外情况的终端或为新应用程序提供默认网页。
Forwarded HeadersForwards proxied headers onto the current request.Before components that consume the updated fields. Examples: scheme, host, client IP, method.转发标头将代理标头转发到当前请求。在使用更新字段的组件之前。示例:方案、主机、客户端 IP、方法。
Health CheckChecks the health of an ASP.NET Core app and its dependencies, such as checking database availability.Terminal if a request matches a health check endpoint.健康检查检查 ASP.NET Core 应用程序及其依赖项的运行状况,例如检查数据库可用性。如果请求与健康检查端点匹配,则终端。
Header PropagationPropagates HTTP headers from the incoming request to the outgoing HTTP Client requests.标头传播将 HTTP 标头从传入请求传播到传出 HTTP 客户端请求。
HTTP LoggingLogs HTTP Requests and Responses.At the beginning of the middleware pipeline.HTTP 日志记录记录 HTTP 请求和响应。在中间件管道的开始处。
HTTP Method OverrideAllows an incoming POST request to override the method.Before components that consume the updated method.HTTP 方法覆盖允许传入的 POST 请求覆盖该方法。在使用更新方法的组件之前。
HTTPS RedirectionRedirect all HTTP requests to HTTPS.Before components that consume the URL.HTTPS 重定向将所有 HTTP 请求重定向到 HTTPS。在使用 URL 的组件之前。
HTTP Strict Transport Security (HSTS)Security enhancement middleware that adds a special response header.Before responses are sent and after components that modify requests. Examples: Forwarded Headers, URL Rewriting.HTTP 严格传输安全 (HSTS)添加特殊响应标头的安全增强中间件。在发送响应之前和修改请求的组件之后。示例:转发标头、URL 重写。
MVCProcesses requests with MVC/Razor Pages.Terminal if a request matches a route.多维控制器使用 MVC/Razor 页面处理请求。如果请求与路由匹配,则终端。
OWINInterop with OWIN-based apps, servers, and middleware.Terminal if the OWIN Middleware fully processes the request.欧文与基于 OWIN 的应用程序、服务器和中间件进行互操作。如果 OWIN 中间件完全处理请求,则终端。
Output CachingProvides support for caching responses based on configuration.Before components that require caching. UseRouting must come before UseOutputCachingUseCORS must come before UseOutputCaching.输出缓存提供对基于配置的缓存响应的支持。在需要缓存的组件之前。UseRouting必须先来UseOutputCachingUseCORS必须先来UseOutputCaching
Response CachingProvides support for caching responses. This requires client participation to work. Use output caching for complete server control.Before components that require caching. UseCORS must come before UseResponseCaching. Is typically not beneficial for UI apps such as Razor Pages because browsers generally set request headers that prevent caching. Output caching benefits UI apps.响应缓存提供对缓存响应的支持。这需要客户的参与才能发挥作用。使用输出缓存来实现完整的服务器控制。在需要缓存的组件之前。UseCORS必须先来UseResponseCaching。对于 Razor Pages 等 UI 应用程序通常没有好处,因为浏览器通常会设置阻止缓存的请求标头。输出缓存有利于 UI 应用程序。
Request DecompressionProvides support for decompressing requests.Before components that read the request body.请求解压提供对解压缩请求的支持。在读取请求正文的组件之前。
Response CompressionProvides support for compressing responses.Before components that require compression.响应压缩提供对压缩响应的支持。在需要压缩的组件之前。
Request LocalizationProvides localization support.Before localization sensitive components. Must appear after Routing Middleware when using RouteDataRequestCultureProvider.请求本地化提供本地化支持。敏感元件本地化之前。使用RouteDataRequestCultureProvider时必须出现在路由中间件之后。
Endpoint RoutingDefines and constrains request routes.Terminal for matching routes.端点路由定义和约束请求路由。匹配路线的终端。
SPAHandles all requests from this point in the middleware chain by returning the default page for the Single Page Application (SPA)Late in the chain, so that other middleware for serving static files, MVC actions, etc., takes precedence.温泉通过返回单页应用程序 (SPA) 的默认页面来处理中间件链中这一点的所有请求在链的后期,以便其他用于提供静态文件、MVC 操作等的中间件优先。
SessionProvides support for managing user sessions.Before components that require Session.会议提供对管理用户会话的支持。在需要 Session 的组件之前。
Static FilesProvides support for serving static files and directory browsing.Terminal if a request matches a file.静态文件提供对服务静态文件和目录浏览的支持。如果请求与文件匹配则终端。
URL RewriteProvides support for rewriting URLs and redirecting requests.Before components that consume the URL.网址重写提供对重写 URL 和重定向请求的支持。在使用 URL 的组件之前。
W3CLoggingGenerates server access logs in the W3C Extended Log File Format.At the beginning of the middleware pipeline.W3C日志记录以W3C 扩展日志文件格式生成服务器访问日志。在中间件管道的开始处。
WebSocketsEnables the WebSockets protocol.Before components that are required to accept WebSocket requests.WebSockets启用 WebSocket 协议。在接受 WebSocket 请求所需的组件之前。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/31313.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

微服务 云原生:基于 Gogs + Drone 实现 CI/CD 自动化

一般构建部署 以一个简单的前后端项目来说,分别编写前后端的 Dockerfile 文件并构建镜像,然后编写 docker-compose.yml 构建部署,启动运行。每次代码变更后都需重新手动打包、构建、推送。 一个简单的例子: 前端: 项…

【力扣每日一题】2023.8.7 反转字符串

目录 题目: 示例: 分析: 代码: 题目: 示例: 分析: 题目给我们一个字符数组形式的字符串,让我们直接原地修改反转字符串,不必返回。 给出的条件是使用O(1)的额外空间…

bash: sudo: command not found的解决方法 | 安装sudo

-bash: sudo: command not found的解决方法 https://www.cnblogs.com/pengpengboshi/p/16159443.html 报错 安装apt-get update报错由于没有公钥,无法验证下列签名: NO_PUBKEY A4B469963BF863CC解决办法是手动加入 (sudo可去掉)…

c# 全网最稳定 企业级 以太网客户端类库 具备即时更新状态,断线三次重拨,稳定收发。

源码下载,带示例 代码实现了一个基本的TCP客户端,能够连接到服务器并发送接收数据。当连接失败时,会进行重连,并在达到最大重连次数后终止连接。使用异步编程模型、实现事件模型以及重连机制。 ConnectAsync(): 这是一个异步方法,用于与服务器建立连接。在方法中,首先初始…

ARM架构银河麒麟docker,源码编译安装GDAL

docker中安装依赖 sudo apt-get update sudo apt-get install build-essential autoconf automake libtool sudo apt-get install libproj-dev libgeos-dev libjson-c-dev libpng-dev libjpeg-dev sudo apt-get install python3-dev sudo apt-get install python3.11-dev去官网…

IO密集时epoll还高效吗?

io特别密集时为什么 epoll 效率不高。原因是: 连接密集(短连接特别多),使用epoll的话,每一次连接需要发生epoll_wait->accpet->epoll_ctl调用,而使用select只需要select->accpet,减少了…

数组和字符串-字符串

最长公共前缀 题意: 给多个字符串,找最长前缀 解: 暴力匹配,先按字典序排序字符串,这样长度短的优先进行匹配,所得字符串就可能偏小 适合a aa aaa aaaa这样的数据,不过对于aa aab aabc aab…

python爬虫相关

目录 初识爬虫 爬虫分类 网络爬虫原理 爬虫基本工作流程 搜索引擎获取新网站的url robots.txt HTHP协议 Resquests模块 前言: 安装 普通请求 会话请求 response的常用方法 简单案例 aiohttp模块 使用前安装模块 具体案例 数据解析 re解析 bs4…

数据治理内容

https://space.bilibili.com/405479587 文章内容来源b站up主,语兴呀 数据治理内容 一.模型: 由于早期业务快速扩张,对元数据把控不到位,导致成熟期出现大量不合规模型 解决:数据标准:元数据补充 建设管控&…

基于长短期神经网络LSTM时间序列回归分析

​目录 背影 摘要 LSTM的基本定义 LSTM实现的步骤 基于长短期神经网络LSTM的回归分析 MATALB代码:基于长短期神经网络的回归分析,基于LSTM的回归预测资源-CSDN文库 https://download.csdn.net/download/abc991835105/88184633 效果图 结果分析 展望 参考论文 背影 LSTM神经…

AutoDL服务器的镜像版本太高,配置python3.7 tensorflow1.15版本的框架的步骤

1.选择一个实例,进入后端界面 2. 更新bashrc中的环境变量 conda init bash && source /root/.bashrc查看虚拟环境 conda info --envs可以看到此时有一个base的虚拟环境 但是它的python版本为3.8.10,无法安装tensorflow1.15,所以我们要创建一个…

PHP面向对象面试题

1、简述面对对象六大设计原则 ? 面向对象六大设计原则是一组指导软件设计的原则,它们有助于提高代码的可维护性、可扩展性和可重用性。这些原则是: 单一职责原则(Single Responsibility Principle,SRP)&a…

Ctfshow web入门 SSTI 模板注入篇 web361-web372 详细题解 全

CTFshow SSTI web361 笔记分享 一、代码块 变量块 {{}} 用于将表达式打印到模板输出 注释块 {##} 注释 控制块 {%%} 可以声明变量,也可以执行语句 {% for i in .__class__.__mro__[1].__subclasses__() %}{% if i.__name___wrap_close %}{% print i.__init__.…

Nacos服务治理—负载均衡

引入负载均衡 在消费方引入负载均衡机制&#xff0c;同时简化获取服务提供者信息的流程 Spring Cloud引入组件LoadBalance实现负载均衡 添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web<…

高等数学:圆周率的计算方法

文章目录 1 割圆术2 无穷级数2.1 拉马努金(Ramanujan)圆周率公式2.2 Chudnovsky圆周率公式2.3 BBP公式2.4 其他级数(1) 自然数倒数偶次方和(2) 泰勒展开(3) 无穷乘积 3 微积分4 概率学(Monte Carlo)5 连分数6 总结 本文将对圆周率 π \color{red}{\pi} π的计算方法作简单整理&…

js 正则表达式

js 正则表达式 http://tool.oschina.net/regex https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions 11 22 333

学习pytorch 3 tensorboard的使用

tensorboard的使用 1. 安装2. add_scalar 查看函数图形3. 查看结果4. add_image() 查看训练步骤中间结果的图片 1. 安装 pytorch conda环境 pip install tensorboard pip install opencv-python2. add_scalar 查看函数图形 常用来查看 train val loss等函数图形 from torch…

解决:Unexpected ‘debugger‘ statement.eslint(no-debugger) (即:页面中的 debugger 标红)的问题

1、问题描述&#xff1a; 其一、报错为&#xff1a; Unexpected debugger statement.eslint(no-debugger) 中文为&#xff1a; 意外的“调试器”语句.eslint&#xff08;无调试器&#xff09; 其二、问题描述为&#xff1a; 在正常的 vue 项目中使用 debugger 的调试过程…

Android上的基于协程的存储框架

在Android上&#xff0c;经常会需要持久化本地数据&#xff0c;比如我们需要缓存用户的配置信息、用户的数据、缓存数据、离线缓存数据等等。我们通常使用的工具为SharePreference、MMKV、DataStore、Room、文件等等。通过使用现有的存储框架&#xff0c;结合协程&#xff0c;我…

十分钟python入门 正则表达式

正则常见的三种功能&#xff0c;它们分别是&#xff1a;校验数据的有效性、查找符合要求的文本以及对文本进行切割和替换等操作。 1.元字符 所谓元字符就是指那些在正则表达式中具有特殊意义的专用字符 元字符大致分成这几类&#xff1a;表示单个特殊字符的&#xff0c;表示…