Codebelt.Extensions.Carter.AspNetCore.Xml 1.0.0

dotnet add package Codebelt.Extensions.Carter.AspNetCore.Xml --version 1.0.0
                    
NuGet\Install-Package Codebelt.Extensions.Carter.AspNetCore.Xml -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="Codebelt.Extensions.Carter.AspNetCore.Xml" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Codebelt.Extensions.Carter.AspNetCore.Xml" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Codebelt.Extensions.Carter.AspNetCore.Xml" />
                    
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 Codebelt.Extensions.Carter.AspNetCore.Xml --version 1.0.0
                    
#r "nuget: Codebelt.Extensions.Carter.AspNetCore.Xml, 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 Codebelt.Extensions.Carter.AspNetCore.Xml@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=Codebelt.Extensions.Carter.AspNetCore.Xml&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Codebelt.Extensions.Carter.AspNetCore.Xml&version=1.0.0
                    
Install as a Cake Tool

Codebelt.Extensions.Carter.AspNetCore.Xml

An XML response negotiator for Carter in ASP.NET Core minimal APIs.

About

Codebelt.Extensions.Carter.AspNetCore.Xml extends the Codebelt.Extensions.Carter package with a dedicated XML response negotiator for Carter, capable of serializing response models to XML format using System.Xml.XmlWriter.

Use this package when you need XML-first integrations and want Carter endpoints to participate in explicit content negotiation.

CSharp Example

Functional-test style sample (same bootstrapping pattern used by this repository):

using System.Net.Http.Headers;
using System.Threading.Tasks;
using Carter;
using Codebelt.Extensions.Carter.Assets;
using Codebelt.Extensions.Carter.AspNetCore.Xml;
using Codebelt.Extensions.Xunit.Hosting.AspNetCore;
using Cuemon.Extensions.AspNetCore.Xml;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

using var response = await MinimalWebHostTestFactory.RunAsync(
    services =>
    {
        services.AddMinimalXmlOptions(o =>
        {
            o.Settings.Writer.Indent = true;
        });
        services.AddCarter(configurator: c => c
            .WithModule<WorldModule>()
            .WithResponseNegotiator<XmlResponseNegotiator>());
        services.AddRouting();
    },
    app =>
    {
        app.UseRouting();
        app.UseEndpoints(endpoints => endpoints.MapCarter());
    },
    _ => { },
    async client =>
    {
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
        return await client.GetAsync("/world/statistical-regions");
    });

Program-style usage for production apps (remember to inherit from ICarterModule for your endpoints and add other services as needed):

using Carter;
using Codebelt.Extensions.Carter.AspNetCore.Xml;
using Cuemon.Extensions.AspNetCore.Xml;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddMinimalXmlOptions();
builder.Services.AddCarter(c => c
    .WithResponseNegotiator<XmlResponseNegotiator>());

var app = builder.Build();
app.MapCarter();
app.Run();
Product Compatible and additional computed target framework versions.
.NET 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 85 3/1/2026

Version: 1.0.0
Availability: .NET 10
 
# New Features
- ADDED XmlResponseNegotiator class in the Codebelt.Extensions.Carter.AspNetCore.Xml namespace that provides an XML response negotiator for Carter, capable of serializing response models to XML format using System.Xml.XmlWriter