Juner.AspNetCore.Sequence 1.0.0

dotnet add package Juner.AspNetCore.Sequence --version 1.0.0
                    
NuGet\Install-Package Juner.AspNetCore.Sequence -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Juner.AspNetCore.Sequence" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Juner.AspNetCore.Sequence" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Juner.AspNetCore.Sequence" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Juner.AspNetCore.Sequence --version 1.0.0
                    
#r "nuget: Juner.AspNetCore.Sequence, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Juner.AspNetCore.Sequence@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Juner.AspNetCore.Sequence&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Juner.AspNetCore.Sequence&version=1.0.0
                    
Install as a Cake Tool

Juner.AspNetCore.Sequence

Streaming support for record‑oriented JSON formats (NDJSON, JSON Lines, JSON Sequence) in ASP.NET Core MVC and Minimal API.

This package integrates Juner.Sequence with ASP.NET Core, providing:

  • Streaming input via SequenceInputFormatter and Sequence<T>
  • Streaming output via JsonSequenceResult, JsonLineResult, NdJsonResult, and SequenceResult
  • Natural Minimal API integration
  • MVC integration through formatters and metadata
  • OpenAPI (.NET 10+) support for streaming schemas
  • Content negotiation for streaming formats

It enables true end‑to‑end streaming pipelines in ASP.NET Core without buffering entire payloads.


Installation

dotnet add package Juner.AspNetCore.Sequence

Quick Start

Minimal API — Streaming JSON Output

app.MapGet("/events", () =>
    TypedResults.JsonSequence(GetEvents()));

static async IAsyncEnumerable<Event> GetEvents()
{
    while (true)
    {
        yield return new Event { Message = "tick", Time = DateTime.UtcNow };
        await Task.Delay(1000);
    }
}

Minimal API — Streaming JSON Input

app.MapPost("/upload", async (Sequence<MyType> items) =>
{
    await foreach (var item in items)
        Console.WriteLine(item);
});

Sequence<T> is an ASP.NET Core–native type that represents a streaming JSON input,
allowing items to be consumed as they arrive without buffering.


Supported Streaming Formats

Format Content-Type Notes
JSON Sequence application/json-seq RFC 7464 (RS‑delimited)
NDJSON application/x-ndjson newline‑delimited
JSON Lines application/jsonl equivalent to NDJSON

Streaming Output

The following return types are supported for streaming responses:

Return Type Streaming? Notes
IAsyncEnumerable<T> ideal for streaming
ChannelReader<T> backpressure‑friendly
IEnumerable<T> buffered
List<T> buffered
T[] buffered
Sequence<T> ASP.NET Core–native streaming

Minimal API Result Types

return TypedResults.JsonSequence(values);
return TypedResults.JsonLine(values);
return TypedResults.NdJson(values);
return TypedResults.Sequence(values); // content negotiation

MVC OutputFormatter

Streaming is enabled when the client sends:

  • Accept: application/json-seq
  • Accept: application/x-ndjson
  • Accept: application/jsonl

Streaming Input

ASP.NET Core actions can accept the following types as streaming input:

Parameter Type Streaming?
Sequence<T>
IAsyncEnumerable<T>
ChannelReader<T>
IEnumerable<T> △ (buffered)
List<T>
T[]

Minimal API Example

app.MapPost("/items", async (Sequence<Item> items) =>
{
    await foreach (var item in items)
        Console.WriteLine(item);
});

MVC InputFormatter

Streaming is enabled for:

  • application/json-seq
  • application/x-ndjson
  • application/jsonl

Content Negotiation

SequenceResult<T> automatically selects the best streaming format based on the client's Accept header.

Accept Output
application/json-seq JSON Sequence
application/x-ndjson NDJSON
application/jsonl JSON Lines
application/json JSON array (non‑streaming)
return TypedResults.Sequence(values);

JSON Array (application/json)

JSON arrays are not true streaming formats, as they require full buffering.

SequenceResult<T> can return JSON arrays, but they are fully buffered.

For true streaming, use:

  • JsonSequenceResult<T>
  • JsonLineResult<T>
  • NdJsonResult<T>

OpenAPI Integration (.NET 10+)

Enable OpenAPI support:

services.AddSequenceOpenApi();

Streaming endpoints are annotated with:

  • x-streaming: true
  • x-itemSchema: { ... }
  • Correct content types per format

Both request and response schemas are generated accurately.


Architecture

graph TD;
    A[Juner.Sequence<br/>Core]
    B[Juner.Http.Sequence]
    C[Juner.AspNetCore.Sequence]

    A --> B
    B --> C

    C --> D[InputFormatter<br/>SequenceInputFormatter]
    C --> E[OutputFormatter<br/>JsonSequence / JsonLine / NdJson]
    C --> F[Result Types<br/>JsonSequenceResult / JsonLineResult / NdJsonResult / SequenceResult]
    C --> G[Sequence<T><br/>Minimal API Integration]
    C --> H[OpenAPI (.NET 10+)]

AOT Considerations

ASP.NET Core MVC formatters rely on:

  • dynamic code generation
  • reflection
  • JsonSerializerOptions and TypeInfoResolver

Because of these framework‑level constraints,
MVC streaming (InputFormatter / OutputFormatter) is not AOT‑safe.

However:

✔ Minimal API is AOT‑friendly

When using only:

  • Sequence<T> (for streaming input)
  • JsonSequenceResult<T>, JsonLineResult<T>, NdJsonResult<T>, SequenceResult<T> (for streaming output)

no MVC formatters are involved, and
Minimal API streaming works under Native AOT.

Summary

Feature AOT‑safe? Notes
Minimal API streaming Uses Sequence<T> and result types only
MVC streaming Requires formatters (dynamic code)
OpenAPI (.NET 10+) Works in both modes
JSON array fallback Uses built‑in JSON serialization

Samples

This repository includes two complete samples:

  • Minimal API JSON Sequence Streaming Sample
  • MVC JSON Sequence Streaming Sample

Both demonstrate:

  • Streaming output (JsonSequenceResult)
  • Streaming input (Sequence<T>)
  • Bidirectional streaming using fetch() with duplex: 'half'
  • Browser‑side JSON Sequence parsing (json-seq-stream)
  • OpenAPI (.NET 10+) integration

Minimal API Sample

Located at:

../samples/AspNetCore.Sequence/MinimalApiJsonSequenceStreamingSample.cs

MVC Sample

Located at:

../samples/AspNetCore.Sequence/MvcJsonSequenceStreamingSample.cs

License

MIT

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 68 3/30/2026
1.0.0-preview-2 73 3/26/2026
1.0.0-preview-1 81 3/21/2026 1.0.0-preview-1 is deprecated because it has critical bugs.