gpt4 book ai didi

c# - 欧文阶段标记

转载 作者:太空狗 更新时间:2023-10-29 23:05:58 25 4
gpt4 key购买 nike

鉴于此在我的应用启动时......

app.Use((context, next) =>
{
return next.Invoke();
}).UseStageMarker(PipelineStage.PostAuthenticate);


app.Use((context, next) =>
{
return next.Invoke();
}).UseStageMarker(PipelineStage.Authenticate);

... 为什么 PostAuthenticate 代码在 Authenticate 代码之前执行?

我的意思不是“为什么第一个 app.use 在第二个 app.use 之前被调用”我的意思是:为什么第一个调用在第二个之前被调用,因为第二个应该在请求中更早发生管道?

编辑

与此问题相关:How am I getting a windows identity in this code?

最佳答案

根据文档,这是设计使然:https://www.asp.net/aspnet/overview/owin-and-katana/owin-middleware-in-the-iis-integrated-pipeline .

阶段标记规则部分,您可以阅读以下内容:

The OWIN pipeline and the IIS pipeline is ordered, therefore calls to app.UseStageMarker must be in order. You cannot set the event handler to an event that precedes the last event registered with to app.UseStageMarker. For example, after calling:

app.UseStageMarker(PipelineStage.Authorize);

calls to app.UseStageMarker passing Authenticate or PostAuthenticate will not be honored, and no exception will be thrown. Owin middleware components (OMCs) run at the latest stage, which by default is PreHandlerExecute. The stage markers are used to make them to run earlier. If you specify stage markers out of order, we round to the earlier marker. In other words, adding a stage marker says "Run no later than stage X". OMC's run at the earliest stage marker added after them in the OWIN pipeline.

关于c# - 欧文阶段标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37165192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com