Enigmatry.Entry.AspNetCore 9.1.1-preview.3

This is a prerelease version of Enigmatry.Entry.AspNetCore.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Enigmatry.Entry.AspNetCore --version 9.1.1-preview.3
                    
NuGet\Install-Package Enigmatry.Entry.AspNetCore -Version 9.1.1-preview.3
                    
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="Enigmatry.Entry.AspNetCore" Version="9.1.1-preview.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Enigmatry.Entry.AspNetCore" Version="9.1.1-preview.3" />
                    
Directory.Packages.props
<PackageReference Include="Enigmatry.Entry.AspNetCore" />
                    
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 Enigmatry.Entry.AspNetCore --version 9.1.1-preview.3
                    
#r "nuget: Enigmatry.Entry.AspNetCore, 9.1.1-preview.3"
                    
#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 Enigmatry.Entry.AspNetCore@9.1.1-preview.3
                    
#: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=Enigmatry.Entry.AspNetCore&version=9.1.1-preview.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Enigmatry.Entry.AspNetCore&version=9.1.1-preview.3&prerelease
                    
Install as a Cake Tool

ASP.NET Core Extensions

A library that provides extensions and utilities for ASP.NET Core applications, enhancing the framework with additional features and patterns.

Intended Usage

Use this library to extend your ASP.NET Core applications with features such as enhanced exception handling, HTTPS security configuration, action result extensions, and transaction handling.

Installation

Add the package to your project:

dotnet add package Enigmatry.Entry.AspNetCore

Usage Examples

Using the Exception Handling Extensions

using Enigmatry.Entry.AspNetCore.Exceptions;
using Microsoft.AspNetCore.Builder;

public class Startup
{
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        // Add global exception handling middleware
        app.UseEntryExceptionHandler();
        
        // Other middleware
        //...
    }
}

Using HTTPS Configuration Extensions

using Enigmatry.Entry.AspNetCore.Security;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // Setup HTTPS with appropriate settings based on environment
        services.AddEntryHttps(Environment);
    }
    
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        // Configure HTTPS middleware with appropriate settings for the environment
        app.UseEntryHttps(env);
        
        // Other middleware...
    }
}

Using Action Result Extensions

using Enigmatry.Entry.AspNetCore;
using Microsoft.AspNetCore.Mvc;
using AutoMapper;

[ApiController]
[Route("api/products")]
public class ProductController : ControllerBase
{
    private readonly ProductService _productService;
    private readonly IMapper _mapper;
    
    public ProductController(ProductService productService, IMapper mapper)
    {
        _productService = productService;
        _mapper = mapper;
    }

    [HttpGet("{id}")]
    public ActionResult<ProductDto> GetProduct(int id)
    {
        // Use extension method to automatically return NotFound if null
        var product = _productService.GetProductById(id);
        return product.ToActionResult();
    }
    
    [HttpGet("{id}/details")]
    public ActionResult<ProductDetailsDto> GetProductDetails(int id)
    {
        // Use extension method to map and handle not found in one call
        var product = _productService.GetProductById(id);
        return _mapper.MapToActionResult<ProductDetailsDto>(product);
    }
}

Using Transaction Filter Attributes

using Enigmatry.Entry.AspNetCore.Filters;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("api/orders")]
public class OrdersController : ControllerBase
{
    private readonly OrderService _orderService;
    
    public OrdersController(OrderService orderService)
    {
        _orderService = orderService;
    }

    [HttpPost]
    [TransactionFilter] // Automatically starts and commits a transaction
    public async Task<ActionResult<OrderDto>> CreateOrder(CreateOrderRequest request)
    {
        var order = await _orderService.CreateOrderAsync(request);
        return Created($"api/orders/{order.Id}", order);
    }
    
    [HttpDelete("{id}")]
    [CancelSavingTransaction] // Prevents transaction from being saved when needed
    public async Task<IActionResult> CancelOrder(int id)
    {
        await _orderService.CancelOrderAsync(id);
        return NoContent();
    }
}

Summary of Available Features

The Enigmatry.Entry.AspNetCore package provides several utilities and extensions:

  1. Exception Handling:

    • UseEntryExceptionHandler() - Configures global exception handling
  2. HTTPS Security:

    • AddEntryHttps() - Configures HTTPS services with environment-specific settings
    • UseEntryHttps() - Adds HTTPS middleware with environment-specific settings
  3. Action Result Extensions:

    • ToActionResult() - Converts models to ActionResult, handling null cases
    • MapToActionResult<T>() - Maps and converts models to ActionResult in one call
  4. Transaction Handling:

    • [TransactionFilter] - Filter attribute for transaction management
    • [CancelSavingTransaction] - Prevents saving in a transaction
  5. Validation Extensions:

    • CamelCasePropertyNameResolver - Helps with FluentValidation integration

Integration Example

Here's how to integrate multiple features from the package:

using Enigmatry.Entry.AspNetCore.Exceptions;
using Enigmatry.Entry.AspNetCore.Security;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        // Add HTTPS services
        services.AddEntryHttps(Environment);
        
        // Add other services
        services.AddControllers();
        services.AddAutoMapper(typeof(Startup).Assembly);
    }
    
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        // Add exception handling
        app.UseEntryExceptionHandler();
        
        // Add HTTPS middleware
        app.UseEntryHttps(env);
        
        // Other middleware
        app.UseRouting();
        app.UseAuthorization();
        app.UseEndpoints(endpoints => 
        {
            endpoints.MapControllers();
        });
    }
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 (1)

Showing the top 1 NuGet packages that depend on Enigmatry.Entry.AspNetCore:

Package Downloads
Enigmatry.Entry.AspNetCore.Authorization

Building Block for adding authorization to AspNet Core applications based on Entry

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.1-preview.4 86 6/27/2025
9.1.1-preview.3 127 6/4/2025
9.1.0 406 6/3/2025
9.0.1-preview.8 122 5/26/2025
9.0.1-preview.7 209 5/13/2025
9.0.1-preview.6 209 5/9/2025
9.0.1-preview.5 146 5/7/2025
9.0.1-preview.4 116 4/30/2025
9.0.1-preview.2 131 4/1/2025
9.0.0 1,049 2/26/2025
8.1.1-preview.3 125 5/7/2025
8.1.1-preview.1 128 4/1/2025
8.1.0 707 2/19/2025
8.0.1-preview.4 70 2/7/2025
8.0.1-preview.2 60 1/15/2025
8.0.0 1,379 11/27/2024
3.4.6-preview.10 76 11/27/2024
3.4.3 2,001 10/22/2024
3.4.2 753 10/11/2024
3.4.1 147 10/9/2024
3.4.0 134 10/9/2024
3.3.2 497 8/28/2024
3.3.2-preview.7 94 8/27/2024
3.3.1 449 7/16/2024
3.3.1-preview.4 77 7/12/2024
3.3.0 1,146 6/20/2024
3.2.1-preview.4 65 6/17/2024
3.2.1-preview.1 83 5/23/2024
3.2.0 4,317 4/3/2024
3.1.1-preview.1 1,018 3/13/2024
3.1.0 340 3/8/2024
3.1.0-preview.2 434 2/19/2024
3.0.1-preview.2 1,140 2/9/2024
3.0.1-preview.1 83 1/24/2024
3.0.0 1,350 1/15/2024
3.0.0-preview.14 134 1/9/2024
3.0.0-preview.12 92 1/9/2024
3.0.0-preview.5 85 1/10/2024
3.0.0-preview.2 134 12/28/2023
3.0.0-preview 164 12/20/2023
2.1.0 195 12/28/2023
2.0.1-preview.3 110 12/1/2023
2.0.1-preview.2 87 11/29/2023
2.0.1-preview.1 82 11/28/2023
2.0.0 475 11/8/2023
2.0.0-preview.3 466 10/27/2023
2.0.0-preview.2 86 10/27/2023
2.0.0-preview.1 88 10/27/2023
2.0.0-preview 147 10/27/2023
1.1.500 180 10/27/2023
1.1.495 916 9/24/2023
1.1.486 480 9/13/2023
1.1.484 263 9/7/2023
1.1.482 194 9/6/2023
1.1.480 290 8/24/2023
1.1.477 511 8/2/2023
1.1.464 258 7/5/2023
1.1.447 235 5/26/2023
1.1.396 319 4/11/2023
1.1.383 299 4/3/2023
1.1.377 300 3/13/2023
1.1.376 287 3/13/2023
1.1.365 996 2/15/2023