ASP.NET Core Minimal API C#
Snippet C# untuk ASP.NET Core Minimal API yang menjawab request ke /pixel.gif dengan empty GIF, yang di-decode sekali saat startup.
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");
Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.
Periksa
curl -sI http://localhost:8080/pixel.gif
Situs resmi: ASP.NET Core Minimal API