Skip to content

Instantly share code, notes, and snippets.

@CoreProgramm
Created April 27, 2020 15:27
Show Gist options
  • Save CoreProgramm/62cfdbc86b2608a5d6273d062e371884 to your computer and use it in GitHub Desktop.
Save CoreProgramm/62cfdbc86b2608a5d6273d062e371884 to your computer and use it in GitHub Desktop.
Custom Middle Ware
// You may need to install the Microsoft.AspNetCore.Http.Abstractions package into your project
public class MyCustomMiddleware
{
private readonly RequestDelegate _next;
public MyCustomMiddleware(RequestDelegate next)
{
_next = next;
}
public Task Invoke(HttpContext httpContext)
{
return _next(httpContext);
}
}
// Extension method used to add the middleware to the HTTP request pipeline.
public static class MyCustomMiddlewareExtensions
{
public static IApplicationBuilder UseMyCustomMiddleware(this IApplicationBuilder builder)
{
return builder.UseMiddleware<MyCustomMiddleware>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment