Apricot Framework

ASP.NET Core Extensions

Streaming multipart uploads, query-aware routing, and one-line CORS, forwarding and cookie setup.

A small set of ASP.NET Core helpers that keep coming up: reading an upload without buffering it, requiring a query-string key at the routing layer, and the three or four lines of host configuration that every service behind a load balancer needs.

Package

PackageWhat it is
ApricotFramework.AspNetCore.ExtensionsEverything below. One package, no dependencies.

There is no separate core package. Every type here needs ASP.NET Core, so the library takes a FrameworkReference to Microsoft.AspNetCore.App — which the runtime already contains, leaving no package versions to keep in step.

Install

dotnet add package ApricotFramework.AspNetCore.Extensions

What is in it

AreaNamespaceFor
Uploads…Extensions.UploadsReading a multipart request section by section
Model binding…Extensions.ModelBindingRequiring a query key; turning form binding off
CORS…Extensions.CorsA named allow-everything policy
Forwarding…Extensions.ForwardingHonouring X-Forwarded-* behind a proxy
Cookies…Extensions.CookiesRequiring HTTPS for every cookie
Configuration…Extensions.ConfigurationBinding a section to a snapshot
HTTP…Extensions.HttpFlattening a query; reading per-request items

Namespaces follow the folder each type lives in, so an editor's import suggestion is enough to find anything; there is no single namespace holding all of it.

The two that carry real behaviour

Most of this library is a shortcut for something you could write inline. Two parts are not:

Uploads reads a multipart body as a stream, so a request larger than available memory costs nothing to accept. It also bounds the work a client can ask for, which the framework's own form reader does not do for every field.

Model binding makes a query-string key part of routing rather than validation, which is how two actions on one route are told apart — and which is why a missing key answers 404 rather than 400.

Warning

AddForwardingConfiguration trusts forwarded headers from any peer. See usage for what that means and how to narrow it.

Continue with usage, uploads or model binding.

On this page