Code: Select all
// my code
app.Use(some middleware);
// class UseExtensions / namespace Microsoft.AspNetCore.Builder
public static IApplicationBuilder Use(this IApplicationBuilder app, Func middleware)
{
return app.Use(next => context => middleware(context, next));
}
// class WebApplication / namespace Microsoft.AspNetCore.Builder
public IApplicationBuilder Use(Func middleware)
{
ApplicationBuilder.Use(middleware);
return this;
}
Code: Select all
next => context => middleware(context, next)
Code: Select all
Func middleware
Könnte mir bitte jemand etwas Licht ins Dunkel bringen, was die mögliche Implementierung einer solchen benannten Methode sein könnte?
Code: Select all
public static IApplicationBuilder Use(this IApplicationBuilder app, Func middleware)
{
// here I want to pass a method name as parameter instead of the lambda-expression
return app.Use(next => context => middleware(context, next));
}
Mobile version