You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the full CSV import example, see [CSV Import](/extensions/csv-helper/csv-import/). For export, see [CSV Export](/extensions/csv-helper/csv-export/).
description: "Stream typed rows as a CSV download using CsvResponse<TRow>."
4
+
---
5
+
6
+
Return `CsvResponse<TRow>` directly from `HandleAsync`. It implements `IResult`, so the framework streams the rows to the response without buffering the entire dataset in memory.
description: "Import CSV data into typed rows using CsvRequest<TRow>."
4
+
---
5
+
6
+
Derive your request type from `CsvRequest<TRow>`. After binding, `request.Rows` contains the parsed rows as `IReadOnlyList<TRow>`.
7
+
8
+
Minimal API requires `BindAsync` to be declared as a non-generic static method on the concrete type, so it cannot be provided by the base class. Declare it in the derived class and delegate to `BindCsvAsync<T>`:
Both `text/csv` direct body and `multipart/form-data` file uploads are supported automatically.
44
+
45
+
For per-row validation, see [Row Validation](/extensions/csv-helper/row-validation/). For custom column mapping, see [Class Map](/extensions/csv-helper/class-map/).
description: "Add typed CSV import and export to your AxisEndpoints with the CsvHelper extension package."
4
+
---
5
+
6
+
The `AxisEndpoints.Extensions.CsvHelper` package adds typed CSV import and export to AxisEndpoints endpoints, backed by [CsvHelper](https://joshclose.github.io/CsvHelper/).
description: "Validate CSV rows with DataAnnotations and surface errors as structured responses."
4
+
---
5
+
6
+
DataAnnotations attributes on `TRow` are validated during binding, one row at a time. All errors are collected before the handler is invoked and surfaced as an RFC 9457 `ValidationProblem` response by `CsvBindingExceptionFilter`.
7
+
8
+
Error keys follow the pattern `"row {n}: {MemberName}"`:
9
+
10
+
```json
11
+
{
12
+
"status": 400,
13
+
"errors": {
14
+
"row 3: Email": ["The Email field is not a valid e-mail address."],
15
+
"row 5: Name": ["The Name field is required."]
16
+
}
17
+
}
18
+
```
19
+
20
+
## Registering the filter
21
+
22
+
Register `CsvBindingExceptionFilter` on any endpoint that accepts a `CsvRequest<TRow>` parameter:
description: "Set up AxisEndpoints in your ASP.NET Core project and create your first endpoint."
4
+
---
5
+
6
+
## Setup in Program.cs
7
+
8
+
Call `AddAxisEndpoints()` on the service collection and `MapAxisEndpoints()` on the application. Both methods scan the entry assembly automatically. Pass an `Assembly` argument to target a specific project.
9
+
10
+
```csharp
11
+
usingAxisEndpoints.Extensions;
12
+
13
+
varbuilder=WebApplication.CreateBuilder(args);
14
+
15
+
builder.Services.AddOpenApi();
16
+
builder.Services.AddAxisEndpoints(); // Discovers and registers all endpoints
17
+
18
+
varapp=builder.Build();
19
+
20
+
app.MapOpenApi();
21
+
app.MapAxisEndpoints(); // Maps all discovered endpoints to the Minimal API pipeline
22
+
23
+
app.Run();
24
+
```
25
+
26
+
## Your first endpoint
27
+
28
+
Here is a complete example of a POST endpoint that creates a user and returns a JSON response:
0 commit comments