是什么让某些东西成为 ASP.NET Core 中的请求功能? [英] What makes something be a request feature in ASP.NET Core?

查看:27
本文介绍了是什么让某些东西成为 ASP.NET Core 中的请求功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 ASP.NET Core 中有一点我相信我还没有完全理解,那就是请求功能的想法.如文档中所述:

There's one point in ASP.NET Core that I believe I didn't fully understand yet and that is the idea of request features. As explained in the docs:

功能接口定义给定请求可能支持的特定 HTTP 功能.服务器定义功能集合以及该服务器支持的初始功能集,但可以使用中间件来增强这些功能.

Feature interfaces define specific HTTP features that a given request may support. Servers define collections of features, and the initial set of features supported by that server, but middleware can be used to enhance these features.

我对此的初步理解是,请求功能是服务器应该公开以在应用程序管道上使用的所有内容.也就是说,服务器应该执行的行为,如发送文件.

My initial understanding about this was that request features are all things a server should expose to be used on the application pipeline. That is, behaviors that a server should perform like sending a file.

另一方面,还有身份验证请求功能.现在,我不确定身份验证是否属于这一类.这似乎不是应用程序应该调用的某些服务器行为,而是应用程序本身的问题.

On the other hand, there's, for example, the authentication request feature. Now, I'm not sure authentication falls into this category. It doesn't seem like some server behavior that the application should call, but rather, a concern of the application itself.

这让我想知道是什么让某些东西成为请求功能.那么,是什么让某些东西成为 ASP.NET Core 中的请求功能呢?我最初的理解是错误的吗?将某项内容设为请求功能的决定背后的原因是什么?

This makes me wonder what really makes something be a request feature. So, what makes something be a request feature in ASP.NET Core? Is my initial understanding wrong? What is behind the decision of making something a request feature?

推荐答案

我对此的初步理解是,请求功能是服务器应该公开以在应用程序管道上使用的所有内容.也就是说,服务器应该执行的行为,如发送文件.

My initial understanding about this was that request features are all things a server should expose to be used on the application pipeline. That is, behaviors that a server should perform like sending a file.

这是 http 功能的一种用途.这也是一种增强或点亮 HttpContext 行为的方法,如缓冲、发送文件、身份验证、websockets.

That's one use of http features. It's also a way to augment or light up behaviors on the HttpContext, like buffering, send file, authentication, websockets.

中间件还可以添加特定于该中间件的功能,您可以看到这样的示例:

Middleware can also add features specific to that middleware, you can see examples of this:

通常,这是一种将每个请求行为和状态从服务器通过中间件传输到应用程序的方式.

Generally it's a way to flow per request behavior and state from the server, through middleware, to the application.

这篇关于是什么让某些东西成为 ASP.NET Core 中的请求功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆