ASP.NET Core Minimal API C#
Ein C#-Snippet für ASP.NET Core Minimal API, das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.
ASP.NET Core Minimal API C#
var gif = Convert.FromBase64String("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
var app = WebApplication.CreateBuilder(args).Build();
app.MapGet("/pixel.gif", (HttpResponse response) =>
{
response.Headers.CacheControl = "no-store";
return TypedResults.Bytes(gif, "image/gif");
});
app.Run("http://0.0.0.0:8080");
Wir haben dieses Snippet ausgeführt und die zurückgegebenen Bytes verglichen.
Prüfen
curl -sI http://localhost:8080/pixel.gif
Offizielle Website: ASP.NET Core Minimal API