Indiko.Hosting.Web 2.2.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package Indiko.Hosting.Web --version 2.2.8
                    
NuGet\Install-Package Indiko.Hosting.Web -Version 2.2.8
                    
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.2.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Indiko.Hosting.Web" Version="2.2.8" />
                    
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.2.8
                    
#r "nuget: Indiko.Hosting.Web, 2.2.8"
                    
#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.2.8
                    
#: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.2.8
                    
Install as a Cake Addin
#tool nuget:?package=Indiko.Hosting.Web&version=2.2.8
                    
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.2.18 39 3/8/2026
2.2.17 29 3/8/2026
2.2.16 34 3/8/2026
2.2.15 36 3/7/2026
2.2.13 32 3/7/2026
2.2.12 35 3/7/2026
2.2.10 34 3/6/2026
2.2.9 34 3/6/2026
2.2.8 34 3/6/2026
2.2.7 36 3/6/2026
2.2.5 36 3/6/2026
2.2.3 34 3/6/2026
2.2.2 31 3/6/2026
2.2.1 35 3/6/2026
2.2.0 33 3/6/2026
2.1.4 80 3/2/2026
2.1.3 90 2/27/2026
2.1.2 309 12/18/2025
2.1.1 721 12/2/2025
2.1.0 693 12/2/2025
Loading failed