Created
April 27, 2020 15:27
-
-
Save CoreProgramm/62cfdbc86b2608a5d6273d062e371884 to your computer and use it in GitHub Desktop.
Custom Middle Ware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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