Indiko.Hosting.Web 2.1.0

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

Indiko.Hosting.Web

Web API hosting implementation for building ASP.NET Core Web APIs with the Indiko framework.

Overview

This package provides a complete hosting solution for ASP.NET Core Web APIs, including standardized startup configuration, CORS policies, API versioning, caching, health checks, and seamless integration with Indiko Blocks.

Features

  • Web Host Bootstrapper: Specialized bootstrapper for Web API applications
  • Base Web Startup: Abstract startup class with common Web API configurations
  • CORS Configuration: Environment-aware CORS policies (permissive in dev, restrictive in production)
  • API Versioning: Built-in API versioning support (development environment)
  • Response Caching: Configurable response caching with cache profiles
  • Health Checks: Built-in health check endpoint at /healthz
  • HTTPS Support: Optional HTTPS redirection and HSTS
  • Forwarded Headers: Support for reverse proxy scenarios
  • JSON Configuration: Reference cycle handling in JSON serialization
  • Request Metadata: Service for accessing HTTP request context

Installation

dotnet add package Indiko.Hosting.Web

Quick Start

Minimal Setup

using Indiko.Hosting.Web;

// Create your startup class
public class Startup : WebStartup
{
    public Startup(IConfiguration configuration, IWebHostEnvironment environment)
        : base(configuration, environment)
    {
    }

    protected override bool AddControllersWithViews => false; // Set to true for MVC
    protected override bool EnableForwardedHeaderOptions => false;
    protected override bool ForceHttps => true;

    public override void ConfigureServices(IServiceCollection services)
    {
        base.ConfigureServices(services); // Call base first
        
        // Add your services
        services.AddScoped<IMyService, MyService>();
    }

    public override void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory logger)
    {
        base.Configure(app, env, logger); // Call base first
        
        // Add custom middleware if needed
    }
}

// Program.cs
class Program
{
    static async Task<int> Main(string[] args)
    {
        return await WebHostBootstrapper.Instance.RunAsync<Startup>(args);
    }
}

Configuration (appsettings.json)

{
  "AllowOrigins": "https://example.com,https://app.example.com",
  "CacheProfiles": {
    "Default": {
      "Duration": 60,
      "Location": "Any"
    },
    "Never": {
      "Duration": 0,
      "Location": "None",
      "NoStore": true
    }
  }
}

Key Components

WebHostBootstrapper

Singleton bootstrapper for Web API applications.

// Run the application
await WebHostBootstrapper.Instance.RunAsync<Startup>(args);

WebStartup

Abstract base class providing common Web API configuration.

public class MyStartup : WebStartup
{
    public MyStartup(IConfiguration configuration, IWebHostEnvironment environment)
        : base(configuration, environment)
    {
    }

    // Configure behavior
    protected override bool AddControllersWithViews => false;
    protected override bool EnableForwardedHeaderOptions => true; // For reverse proxy
    protected override bool ForceHttps => true; // Force HTTPS redirect
}

RequestMetadataService

Access HTTP request context information.

public class MyController : ControllerBase
{
    private readonly IRequestMetadataService _requestMetadata;

    public MyController(IRequestMetadataService requestMetadata)
    {
        _requestMetadata = requestMetadata;
    }

    [HttpGet]
    public IActionResult Get()
    {
        var userAgent = _requestMetadata.GetUserAgent();
        var ipAddress = _requestMetadata.GetClientIpAddress();
        // ...
    }
}

Features in Detail

CORS Configuration

Development Environment:

  • Allows any origin, method, and header (permissive for testing)

Production Environment:

  • Reads AllowOrigins from configuration
  • Supports multiple origins (comma-separated)
  • Enables credentials
  • Supports wildcard subdomains

Response Caching

Configure cache profiles in appsettings.json:

{
  "CacheProfiles": {
    "Short": {
      "Duration": 30,
      "Location": "Any",
      "VaryByHeader": "Accept"
    },
    "Long": {
      "Duration": 3600,
      "Location": "Any"
    }
  }
}

Use in controllers:

[HttpGet]
[ResponseCache(CacheProfileName = "Short")]
public IActionResult GetData()
{
    // ...
}

API Versioning

Enabled automatically in development:

[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
public class UsersController : ControllerBase
{
    // ...
}

Health Checks

Built-in endpoint at /healthz:

curl https://your-api.com/healthz

Add custom health checks:

public override void ConfigureServices(IServiceCollection services)
{
    base.ConfigureServices(services);
    
    services.AddHealthChecks()
        .AddDbContextCheck<MyDbContext>()
        .AddUrlGroup(new Uri("https://external-api.com"), "External API");
}

Environment-Specific Behavior

Development

  • Developer exception page
  • Permissive CORS
  • API versioning enabled
  • Forwarded headers (if enabled)

Production

  • HTTPS redirection
  • HSTS enabled
  • Configured CORS policies
  • Forwarded headers (if enabled)

Target Framework

  • .NET 10

Dependencies

  • Indiko.Hosting.Abstractions
  • Indiko.Blocks.Common.Abstractions
  • Indiko.Blocks.Common.Management
  • Microsoft.AspNetCore.App
  • Asp.Versioning.Mvc.ApiExplorer

License

See LICENSE file in the repository root.

  • Indiko.Hosting.Abstractions - Core hosting abstractions
  • Indiko.Hosting.Mvc - MVC application hosting
  • Indiko.Blocks.API.Swagger - Swagger/OpenAPI documentation
  • Indiko.Blocks.API.Compression - Response compression
  • Indiko.Blocks.Security.Authentication.ASPNetCore - Authentication
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
2.1.1 26 12/2/2025
2.1.0 27 12/2/2025
2.0.0 265 9/17/2025
1.7.23 304 9/8/2025
1.7.22 167 9/8/2025
1.7.21 179 8/14/2025
1.7.20 225 6/23/2025
1.7.19 189 6/3/2025
1.7.18 180 5/29/2025
1.7.17 196 5/26/2025
1.7.15 137 4/12/2025
1.7.14 159 4/11/2025
1.7.13 136 3/29/2025
1.7.12 168 3/28/2025
1.7.11 167 3/28/2025
1.7.10 161 3/28/2025
1.7.9 165 3/28/2025
1.7.8 179 3/28/2025
1.7.5 215 3/17/2025
1.7.4 168 3/16/2025
1.7.3 172 3/16/2025
1.7.2 191 3/16/2025
1.7.1 215 3/11/2025
1.6.8 191 3/11/2025
1.6.7 261 3/4/2025
1.6.6 160 2/26/2025
1.6.5 185 2/20/2025
1.6.4 150 2/20/2025
1.6.3 181 2/5/2025
1.6.2 152 1/24/2025
1.6.1 133 1/24/2025
1.6.0 160 1/16/2025
1.5.2 129 1/16/2025
1.5.1 168 11/3/2024
1.5.0 146 10/26/2024
1.3.2 152 10/24/2024
1.3.0 148 10/10/2024
1.2.5 150 10/9/2024
1.2.4 173 10/8/2024
1.2.1 160 10/3/2024
1.2.0 142 9/29/2024
1.1.1 142 9/23/2024
1.1.0 167 9/18/2024
1.0.33 177 9/15/2024
1.0.28 158 8/28/2024
1.0.27 177 8/24/2024
1.0.26 151 7/7/2024
1.0.25 159 7/6/2024
1.0.24 151 6/25/2024
1.0.23 173 6/1/2024
1.0.22 174 5/14/2024
1.0.21 162 5/14/2024
1.0.20 181 4/8/2024
1.0.19 147 4/3/2024
1.0.18 177 3/23/2024
1.0.17 179 3/19/2024
1.0.16 172 3/19/2024
1.0.15 167 3/11/2024
1.0.14 182 3/10/2024
1.0.13 176 3/6/2024
1.0.12 191 3/1/2024
1.0.11 181 3/1/2024
1.0.10 181 3/1/2024
1.0.9 203 3/1/2024
1.0.8 184 2/19/2024
1.0.7 187 2/17/2024
1.0.6 165 2/17/2024
1.0.5 164 2/17/2024
1.0.4 184 2/7/2024
1.0.3 170 2/6/2024
1.0.1 162 2/6/2024
1.0.0 227 1/9/2024
1.0.0-preview99 201 12/22/2023
1.0.0-preview98 151 12/21/2023
1.0.0-preview97 152 12/21/2023
1.0.0-preview96 154 12/20/2023
1.0.0-preview94 148 12/18/2023
1.0.0-preview93 276 12/13/2023
1.0.0-preview92 144 12/13/2023
1.0.0-preview91 204 12/12/2023
1.0.0-preview90 166 12/11/2023
1.0.0-preview89 144 12/11/2023
1.0.0-preview88 248 12/6/2023
1.0.0-preview87 170 12/6/2023
1.0.0-preview86 160 12/6/2023
1.0.0-preview85 145 12/6/2023
1.0.0-preview84 155 12/5/2023
1.0.0-preview83 203 12/5/2023
1.0.0-preview82 181 12/5/2023
1.0.0-preview81 140 12/4/2023
1.0.0-preview80 154 12/1/2023
1.0.0-preview77 159 12/1/2023
1.0.0-preview76 168 12/1/2023
1.0.0-preview75 160 12/1/2023
1.0.0-preview74 178 11/26/2023
1.0.0-preview73 182 11/7/2023
1.0.0-preview72 155 11/6/2023
1.0.0-preview71 154 11/3/2023
1.0.0-preview70 147 11/2/2023
1.0.0-preview69 167 11/2/2023
1.0.0-preview68 146 11/2/2023
1.0.0-preview67 177 11/2/2023
1.0.0-preview66 160 11/2/2023
1.0.0-preview65 146 11/2/2023
1.0.0-preview64 152 11/2/2023
1.0.0-preview63 148 11/2/2023
1.0.0-preview62 155 11/1/2023
1.0.0-preview61 154 11/1/2023
1.0.0-preview60 165 11/1/2023
1.0.0-preview59 144 11/1/2023
1.0.0-preview58 166 10/31/2023
1.0.0-preview57 156 10/31/2023
1.0.0-preview56 157 10/31/2023
1.0.0-preview55 166 10/31/2023
1.0.0-preview54 180 10/31/2023
1.0.0-preview53 135 10/31/2023
1.0.0-preview52 141 10/31/2023
1.0.0-preview51 147 10/31/2023
1.0.0-preview50 171 10/31/2023
1.0.0-preview48 142 10/31/2023
1.0.0-preview46 131 10/31/2023
1.0.0-preview45 146 10/31/2023
1.0.0-preview44 136 10/31/2023
1.0.0-preview43 151 10/31/2023
1.0.0-preview42 183 10/30/2023
1.0.0-preview41 154 10/30/2023
1.0.0-preview40 146 10/27/2023
1.0.0-preview39 154 10/27/2023
1.0.0-preview38 151 10/27/2023
1.0.0-preview37 157 10/27/2023
1.0.0-preview36 143 10/27/2023
1.0.0-preview35 156 10/27/2023
1.0.0-preview34 155 10/27/2023
1.0.0-preview33 136 10/26/2023
1.0.0-preview32 152 10/26/2023
1.0.0-preview31 154 10/26/2023
1.0.0-preview30 162 10/26/2023
1.0.0-preview29 160 10/26/2023
1.0.0-preview28 172 10/26/2023
1.0.0-preview27 168 10/26/2023
1.0.0-preview26 155 10/25/2023
1.0.0-preview25 174 10/23/2023
1.0.0-preview24 146 10/23/2023
1.0.0-preview23 153 10/23/2023
1.0.0-preview22 119 10/23/2023
1.0.0-preview21 160 10/23/2023
1.0.0-preview20 188 10/20/2023
1.0.0-preview19 150 10/19/2023
1.0.0-preview18 165 10/18/2023
1.0.0-preview16 147 10/11/2023
1.0.0-preview14 149 10/10/2023
1.0.0-preview13 150 10/10/2023
1.0.0-preview12 146 10/9/2023
1.0.0-preview11 133 10/9/2023
1.0.0-preview101 132 1/5/2024