加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

什么使ASP.NET Core中的请求功能成为现实?

发布时间:2020-12-16 06:55:07 所属栏目:asp.Net 来源:网络整理
导读:ASP.NET Core中有一点我认为我还没有完全理解,这就是请求功能的想法.如 the docs中所述: Feature interfaces define specific HTTP features that a given request may support. Servers define collections of features,and the initial set of features s
ASP.NET Core中有一点我认为我还没有完全理解,这就是请求功能的想法.如 the docs中所述:

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.

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

另一方面,例如,存在认证请求特征.现在,我不确定身份验证属于这一类.它似乎不是应用程序应该调用的某些服务器行为,而是应用程序本身的一个问题.

这让我想知道什么才能真正成为一个请求功能.那么,什么使得某些东西成为ASP.NET Core中的请求功能?我最初的理解是错的吗?做出请求功能的决定背后是什么?

解决方法

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.

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

>异常处理程序中间件流动通过请求功能发生的异常 – https://github.com/aspnet/Diagnostics/blob/dev/src/Microsoft.AspNetCore.Diagnostics.Abstractions/IExceptionHandlerFeature.cs.
>路由中间件通过请求功能将路由数据添加到当前http上下文 – https://github.com/aspnet/Routing/blob/dev/src/Microsoft.AspNetCore.Routing.Abstractions/IRoutingFeature.cs

通常,它是一种从服务器,中间件到应用程序的每个请求行为和状态的流动方式.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读