Encamina.Enmarcha.AspNet.Mvc.Formatters 8.1.7-preview-06

This is a prerelease version of Encamina.Enmarcha.AspNet.Mvc.Formatters.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Encamina.Enmarcha.AspNet.Mvc.Formatters --version 8.1.7-preview-06                
NuGet\Install-Package Encamina.Enmarcha.AspNet.Mvc.Formatters -Version 8.1.7-preview-06                
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="Encamina.Enmarcha.AspNet.Mvc.Formatters" Version="8.1.7-preview-06" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Encamina.Enmarcha.AspNet.Mvc.Formatters --version 8.1.7-preview-06                
#r "nuget: Encamina.Enmarcha.AspNet.Mvc.Formatters, 8.1.7-preview-06"                
#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.
// Install Encamina.Enmarcha.AspNet.Mvc.Formatters as a Cake Addin
#addin nuget:?package=Encamina.Enmarcha.AspNet.Mvc.Formatters&version=8.1.7-preview-06&prerelease

// Install Encamina.Enmarcha.AspNet.Mvc.Formatters as a Cake Tool
#tool nuget:?package=Encamina.Enmarcha.AspNet.Mvc.Formatters&version=8.1.7-preview-06&prerelease                

ASP.NET - MVC Formatters

Nuget package

ASP.NET MVC Formatters is a project that provides input and output formatters for enhancing the functionality of ASP.NET MVC applications. These formatters are designed to simplify the handling of data input and output, making it more convenient and efficient for developers to work with MVC projects.

Setup

Nuget package

First, install NuGet. Then, install Encamina.Enmarcha.AspNet.Mvc.Formatters from the package manager console:

PM> Install-Package Encamina.Enmarcha.AspNet.Mvc.Formatters

.NET CLI:

First, install .NET CLI. Then, install Encamina.Enmarcha.AspNet.Mvc.Formatters from the .NET CLI:

dotnet add package Encamina.Enmarcha.AspNet.Mvc.Formatters

How to use

Output formatters

Starting from a Program.cs or a similar entry point file in your MVC project, add the following code.

// Entry point
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
   // ...
});

// ...

builder.Services
    .AddControllers()
    // Adds csv output formatter
    .AddCsvOutputFormatter(options =>
    {
        options.Delimiter = ','; // The values delimiter or separator
        options.UseHeader = true; // A flag indicating whether the comma separated values should include a header (line) or not
        options.Encoding = System.Text.Encoding.UTF8.WebName; // Encoding
    })
    // Adds csv output formatter
    .AddPdfOutputFormatter();

// ...

The extension methods AddCsvOutputFormatter and AddPdfOutputFormatter handle the configuration to enable any endpoint to support returning data not only in the default JSON format but also in CSV or PDF formats.

curl --location 'https://my-endpoint.net/controller' \
--header 'Accept: text/csv'
# Response: 200 OK with CSV data

curl --location 'https://my-endpoint.net/controller' \
--header 'Accept: application/pdf'
# Response: 200 OK with PDF data

Input formatters

Starting from a Program.cs or a similar entry point file in your MVC project, add the following code.

// Entry point
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
   // ...
});

// ...

builder.Services
    .AddControllers()
    // Adds csv output formatter
    .AddCsvInputFormatter(options =>
    {
        options.Delimiter = ','; // The values delimiter or separator
        options.UseHeader = true; // A flag indicating whether the comma separated values should include a header (line) or not
        options.Encoding = System.Text.Encoding.UTF8.WebName; // Encoding
    });

// ...

The extension method AddCsvInputFormatter is responsible for configuring everything necessary to enable any endpoint to support receiving information through the body in CSV format.

curl --location 'https://localhost:7184/weatherforecast' \
--header 'Content-Type: text/csv' \
--data 'Foo,Bar
Foo Value,100
Other foo Value, 150'
# Response: 200 OK
Product Compatible and additional computed target framework versions.
.NET 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. 
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
8.2.0 78 10/22/2024
8.2.0-preview-01-m01 105 9/17/2024
8.1.9-preview-03 54 11/19/2024
8.1.9-preview-02 66 10/22/2024
8.1.9-preview-01 61 10/4/2024
8.1.8 84 9/23/2024
8.1.8-preview-07 84 9/12/2024
8.1.8-preview-06 88 9/11/2024
8.1.8-preview-05 85 9/10/2024
8.1.8-preview-04 97 8/16/2024
8.1.8-preview-03 95 8/13/2024
8.1.8-preview-02 94 8/13/2024
8.1.8-preview-01 105 8/12/2024
8.1.7 100 8/7/2024
8.1.7-preview-09 84 7/3/2024
8.1.7-preview-08 88 7/2/2024
8.1.7-preview-07 84 6/10/2024
8.1.7-preview-06 76 6/10/2024
8.1.7-preview-05 88 6/6/2024
8.1.7-preview-04 89 6/6/2024
8.1.7-preview-03 98 5/24/2024
8.1.7-preview-02 80 5/10/2024
8.1.7-preview-01 78 5/8/2024
8.1.6 110 5/7/2024
8.1.6-preview-08 57 5/2/2024
8.1.6-preview-07 84 4/29/2024
8.1.6-preview-06 104 4/26/2024
8.1.6-preview-05 110 4/24/2024
8.1.6-preview-04 76 4/22/2024
8.1.6-preview-03 84 4/22/2024
8.1.6-preview-02 84 4/17/2024
8.1.6-preview-01 88 4/15/2024
8.1.5 126 4/15/2024
8.1.5-preview-15 82 4/10/2024
8.1.5-preview-14 84 3/20/2024
8.1.5-preview-13 68 3/18/2024
8.1.5-preview-12 96 3/13/2024
8.1.5-preview-11 78 3/13/2024
8.1.5-preview-10 83 3/13/2024
8.1.5-preview-09 81 3/12/2024
8.1.5-preview-08 74 3/12/2024
8.1.5-preview-07 80 3/8/2024
8.1.5-preview-06 72 3/8/2024
8.1.5-preview-05 93 3/7/2024
8.1.5-preview-04 78 3/7/2024
8.1.5-preview-03 87 3/7/2024
8.1.5-preview-02 82 2/28/2024
8.1.5-preview-01 85 2/19/2024
8.1.4 122 2/15/2024
8.1.3 116 2/13/2024
8.1.3-preview-07 91 2/13/2024
8.1.3-preview-06 81 2/12/2024
8.1.3-preview-05 91 2/9/2024
8.1.3-preview-04 86 2/8/2024
8.1.3-preview-03 86 2/7/2024
8.1.3-preview-02 89 2/2/2024
8.1.3-preview-01 85 2/2/2024
8.1.2 118 2/1/2024
8.1.2-preview-9 84 1/22/2024
8.1.2-preview-8 82 1/19/2024
8.1.2-preview-7 85 1/19/2024
8.1.2-preview-6 80 1/19/2024
8.1.2-preview-5 83 1/19/2024
8.1.2-preview-4 88 1/19/2024
8.1.2-preview-3 85 1/18/2024
8.1.2-preview-2 88 1/18/2024
8.1.2-preview-16 87 1/31/2024
8.1.2-preview-15 91 1/31/2024
8.1.2-preview-14 72 1/25/2024
8.1.2-preview-13 75 1/25/2024
8.1.2-preview-12 79 1/23/2024
8.1.2-preview-11 74 1/23/2024
8.1.2-preview-10 88 1/22/2024
8.1.2-preview-1 79 1/18/2024
8.1.1 122 1/18/2024
8.1.0 109 1/18/2024
8.0.3 160 12/29/2023
8.0.1 129 12/14/2023
8.0.0 150 12/7/2023
6.0.4.3 115 12/29/2023
6.0.4.2 129 12/20/2023
6.0.4.1 97 12/19/2023
6.0.4 152 12/4/2023
6.0.3.20 125 11/27/2023
6.0.3.19 141 11/22/2023