Amazon.Lambda.AspNetCoreServer.Hosting 1.10.0

Prefix Reserved
dotnet add package Amazon.Lambda.AspNetCoreServer.Hosting --version 1.10.0
                    
NuGet\Install-Package Amazon.Lambda.AspNetCoreServer.Hosting -Version 1.10.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="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.10.0" />
                    
Directory.Packages.props
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" />
                    
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 Amazon.Lambda.AspNetCoreServer.Hosting --version 1.10.0
                    
#r "nuget: Amazon.Lambda.AspNetCoreServer.Hosting, 1.10.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 Amazon.Lambda.AspNetCoreServer.Hosting@1.10.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=Amazon.Lambda.AspNetCoreServer.Hosting&version=1.10.0
                    
Install as a Cake Addin
#tool nuget:?package=Amazon.Lambda.AspNetCoreServer.Hosting&version=1.10.0
                    
Install as a Cake Tool

Amazon.Lambda.AspNetCoreServer.Hosting

This package allows ASP .NET Core applications written using the minimal api style to be deployed as AWS Lambda functions. This is done by adding a call to AddAWSLambdaHosting to the services collection of the application. This method takes in the LambdaEventSource enum that configures which Lambda event source the Lambda function will be configured for.

The AddAWSLambdaHosting will setup the Amazon.Lambda.AspNetCoreServer package to process the incoming Lambda events as ASP .NET Core requests. It will also initialize Amazon.Lambda.RuntimeSupport package to interact with the Lambda service.

Supported .NET versions

This library supports .NET 6 and above. Lambda provides managed runtimes for long term supported (LTS) versions like .NET 6 and .NET 8. To use standard term supported (STS) versions like .NET 9 the Lambda function must be bundled as a self contained executable or an OCI image.

Sample ASP .NET Core application

The code sample below is the typical initilization code for an ASP .NET Core application using the minimal api style. The one difference is the extra line of code calling AddAWSLambdaHosting.

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// Register Lambda to replace Kestrel as the web server for the ASP.NET Core application.
// If the application is not running in Lambda then this method will do nothing. 
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi);

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();

Extension Points

AddAWSLambdaHosting accepts an optional HostingOptions configuration action that exposes the same customization hooks available in the traditional AbstractAspNetCoreFunction base class approach.

Binary response handling

By default, common binary content types like image/png and application/pdf are already configured for Base64 encoding. You can register additional types or override the default encoding:

builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi, options =>
{
    // Register a custom binary content type
    options.RegisterResponseContentEncodingForContentType("application/x-custom-binary", ResponseContentEncoding.Base64);

    // Ensure compressed responses are Base64-encoded (gzip, deflate, br are already defaults)
    options.RegisterResponseContentEncodingForContentEncoding("zstd", ResponseContentEncoding.Base64);

    // Change the fallback encoding for any unregistered content type
    options.DefaultResponseContentEncoding = ResponseContentEncoding.Base64;
});

Exception details in responses

Useful during development to surface unhandled exception details in the HTTP response body:

builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi, options =>
{
    options.IncludeUnhandledExceptionDetailInResponse = app.Environment.IsDevelopment();
});

Customizing request and response marshalling

Callbacks let you inspect or modify the ASP.NET Core feature objects after the Lambda event has been marshalled into them. The second parameter is the raw Lambda request or response object — cast it to the appropriate type for your event source (APIGatewayHttpApiV2ProxyRequest for HttpApi, APIGatewayProxyRequest for RestApi, ApplicationLoadBalancerRequest for ApplicationLoadBalancer).

builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi, options =>
{
    // Add a custom header derived from the raw Lambda request
    options.PostMarshallRequestFeature = (requestFeature, lambdaRequest, context) =>
    {
        var apiRequest = (APIGatewayHttpApiV2ProxyRequest)lambdaRequest;
        requestFeature.Headers["X-Stage"] = apiRequest.RequestContext.Stage;
    };

    // Inject the Lambda context into HttpContext.Items for use in middleware or controllers
    options.PostMarshallItemsFeature = (itemsFeature, lambdaRequest, context) =>
    {
        itemsFeature.Items["MyCustomKey"] = context.FunctionName;
    };

    // Modify the response after it has been marshalled back to a Lambda response
    options.PostMarshallResponseFeature = (responseFeature, lambdaResponse, context) =>
    {
        var apiResponse = (APIGatewayHttpApiV2ProxyResponse)lambdaResponse;
        apiResponse.Headers ??= new Dictionary<string, string>();
        apiResponse.Headers["X-Request-Id"] = context.AwsRequestId;
    };
});
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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 was computed.  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 was computed.  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 (6)

Showing the top 5 NuGet packages that depend on Amazon.Lambda.AspNetCoreServer.Hosting:

Package Downloads
Fen.Service

Standardized Service conventions, from the opinions of the Fulfiller Enablement team.

Siemens.AspNet.MinimalApi.Sdk

A library which contains following functions: - Siemens.AspNet.MinimalApi.Sdk

Siemens.AspNet.Lambda.Sdk.Contracts

The Siemens.AspNet.Lambda.Sdk.Contracts NuGet package simplifies and accelerates the development of AWS Lambda functions using ASP.NET-inspired middleware pipelines, structured exception handling, and pre-configured startup patterns.

Siemens.AspNet.DbProvider

A library which contains following functions: - Siemens.AspNet.DbProvider

JuegoFramework

Package Description

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Amazon.Lambda.AspNetCoreServer.Hosting:

Repository Stars
Elfocrash/aws-videos
aws-samples/serverless-dotnet-demo
Version Downloads Last Updated
1.10.0 0 2/19/2026
1.9.1 83,609 1/12/2026
1.9.0 845,293 7/15/2025
1.8.2 193,597 6/3/2025
1.8.1 97,366 5/15/2025
1.8.0 97,137 4/25/2025
1.7.4 481,994 2/25/2025
1.7.3 517,439 11/26/2024
1.7.2 179,962 11/20/2024
1.7.1 613,929 9/5/2024
1.7.0 1,348,447 2/16/2024
1.6.1 446,553 11/14/2023
1.6.0 1,104,356 3/24/2023
1.5.1 122,809 3/1/2023
1.5.0 292,754 12/9/2022
1.4.0 34,129 12/7/2022
1.3.1 818,593 5/27/2022
1.3.0 113,858 5/18/2022
1.2.0 13,037 5/7/2022
1.1.0 178,646 3/15/2022
Loading failed