我必须在其他地方激活它还是你可以帮助我?当我运行该项目时,它直接进入控制器并且中间件不运行。
这是我的中间件。
public class AuthenticationMiddleWare
{
private RequestDelegate nextDelegate;
public AuthenticationMiddleWare(RequestDelegate next, IConfiguration config)
{
nextDelegate = next;
}
public async Task Invoke(HttpContext httpContext)
{
try
{
// somecode
await nextDelegate.Invoke(httpContext);
}
catch (Exception ex)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)