Owin Stage Markers

前端 未结 2 1262
夕颜
夕颜 2021-01-12 16:29

Given this in my app startup ...

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


app.Use((conte         


        
相关标签:
2条回答
  • 2021-01-12 17:05

    It seems that even contrary to the documentation events in IIS are hooked up and processed in the order they are configured rather than in the order they should appear in the request lifecycle.

    This feels like a bug in the owin request lifecycle to me but hey, I got my problem solved.

    0 讨论(0)
  • 2021-01-12 17:09

    It's by design, according to the documentation: https://www.asp.net/aspnet/overview/owin-and-katana/owin-middleware-in-the-iis-integrated-pipeline.

    In the section Stage Marker Rules, you could read the following:

    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.

    0 讨论(0)
提交回复
热议问题