繁体   English   中英

async、await、context 和 next 在当前上下文中不存在

[英]async, await, context and next does not exist in the current context

我刚刚使用 Core 2.2 创建了一个新的空 Web 应用程序,并想添加一个中间件,但我不允许这样做。

app.Use(async (context, next)) =>
        {
            await next;
        }

但它不能识别异步、上下文、下一步或等待。 我试过在线搜索,但没有遇到任何关于这个微不足道的问题。 有谁知道是什么原因造成的? 我正在使用社区 2019

它应该是

app.Use(async (context, next) =>
    {
        await next();
    })

app.Use()接受一个函数作为参数,但你只传递async (context, next)作为参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM