ASP.NET Core Minimal API C#
ASP.NET Core Minimal API માટે C# સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.
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");
અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.
ચકાસો
curl -sI http://localhost:8080/pixel.gif
સત્તાવાર સાઇટ: ASP.NET Core Minimal API