emptygif
Basa: Basa Jawa

Kabeh basa lan framework

ASP.NET Core Minimal API C#

Snippet C# kanggo ASP.NET Core Minimal API sing mangsuli request menyang /pixel.gif nganggo empty GIF, sing didekode sepisan nalika startup.

ASP.NET Core Minimal API C#

Instal
dotnet new web
File
Program.cs
Lakokake
dotnet run
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");

Snippet iki wis dilakokake lan byte asile wis dibandhingake.

Priksa

curl -sI http://localhost:8080/pixel.gif

Situs resmi: ASP.NET Core Minimal API

Liyane ing C#