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
<PackageReference Include="Juner.AspNetCore.Sequence" Version="1.0.0" />
<PackageVersion Include="Juner.AspNetCore.Sequence" Version="1.0.0" />
<PackageReference Include="Juner.AspNetCore.Sequence" />
paket add Juner.AspNetCore.Sequence --version 1.0.0
#r "nuget: Juner.AspNetCore.Sequence, 1.0.0"
#:package Juner.AspNetCore.Sequence@1.0.0
#addin nuget:?package=Juner.AspNetCore.Sequence&version=1.0.0
#tool nuget:?package=Juner.AspNetCore.Sequence&version=1.0.0
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
SequenceInputFormatterandSequence<T> - Streaming output via
JsonSequenceResult,JsonLineResult,NdJsonResult, andSequenceResult - 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-seqAccept: application/x-ndjsonAccept: 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-seqapplication/x-ndjsonapplication/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: truex-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
JsonSerializerOptionsandTypeInfoResolver
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()withduplex: '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 | Versions 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. |
-
net10.0
- Juner.Sequence (>= 1.0.0)
- Microsoft.AspNetCore.OpenApi (>= 10.0.5)
-
net7.0
- Juner.Sequence (>= 1.0.0)
-
net8.0
- Juner.Sequence (>= 1.0.0)
-
net9.0
- Juner.Sequence (>= 1.0.0)
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 |