As per my understanding, we need to use the next(context) to call the next request delegate/middleware. I have gone through multiple online resources, but have not found an exact difference between next(context) and next.Invoke(context).
I want to use next(context) in place of next.Invoke(context) in existing code written by another person based on my learning. If I am using next() instead of next.Invoke(context), everything is working fine. I want to know if it will impact anything or there is any difference between these two calls.
next
is a RequestDelegate
in this context, hence there is no functional difference between next(context)
and next.Invoke(context)
. next(context)
will be translated to next.Invoke(context)
.
Please note that you'll need to await next(context)
in the same situations as with next.Invoke(context)
.
More info on custom middleware: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/write?view=aspnetcore-5.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With