csharp-sse-support

star 0

This skill describes how to implement the server part of Server-Sent Events (SSE) in modern .NET (ASP.NET Core). Use this skill when the user asks about "SSE in .NET / ASP.NET Core".

rstropek By rstropek schedule Updated 1/27/2026

name: csharp-sse-support description: This skill describes how to implement the server part of Server-Sent Events (SSE) in modern .NET (ASP.NET Core). Use this skill when the user asks about "SSE in .NET / ASP.NET Core".

ASP.NET Core Minimal APIs have built-in SSE result support in ASP.NET Core 10 via Results.ServerSentEvents(...) / TypedResults.ServerSentEvents(...) returning a ServerSentEventsResult<T> from an IAsyncEnumerable.

Minimal API example (strings)

app.MapGet("/events", () =>
{
    async IAsyncEnumerable<string> Stream([System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct = default)
    {
        while (!ct.IsCancellationRequested)
        {
            yield return $"Server time: {DateTimeOffset.UtcNow:O}";
            await Task.Delay(1000, ct);
        }
    }

    // Sends SSE data using built-in result support
    return Results.ServerSentEvents(Stream());
});
Install via CLI
npx skills add https://github.com/rstropek/2026-01-27-copilot --skill csharp-sse-support
Repository Details
star Stars 0
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator