Pass data to middleware further down the chain

前端 未结 2 1998
有刺的猬
有刺的猬 2021-02-18 20:10

When I register middleware as part of the request pipeline, how do I pass data through the middleware chain. (ultimately accessible in an MVC controller action)

For exam

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-18 20:49

    You can store custom data in IOwinContext object. IOwinContext object can be accessed from Invoke function of your middleware.

    Set

    context.Set("key", obj);
    

    Get

    var obj = context.Get("key");
    

提交回复
热议问题