Regira.Web 6.1.2

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

Regira Web.HTML

Regira Web.HTML provides Razor-based HTML template rendering plus common web utilities, middleware, and Swagger configuration.

Projects

Project Package Purpose
Common.Web Regira.Web Core web utilities, middleware, exception handling
Web.HTML.RazorEngineCore Regira.Web.HTML.RazorEngineCore Razor templates via RazorEngineCore
Web.HTML.RazorLight Regira.Web.HTML.RazorLight Razor templates via RazorLight
Web.Swagger Regira.Web.Swagger Swagger/OpenAPI JWT & API Key support
System.Hosting Regira.System.Hosting Host config, background tasks, Windows Service

Installation


<PackageReference Include="Regira.Web" Version="6.*" />


<PackageReference Include="Regira.Web.HTML.RazorEngineCore" Version="6.*" />
<PackageReference Include="Regira.Web.HTML.RazorLight" Version="6.*" />


<PackageReference Include="Regira.Web.Swagger" Version="6.*" />


<PackageReference Include="Regira.System.Hosting" Version="6.*" />

HTML Template Parsing

IHtmlParser

Task<string> Parse<T>(string html, T model);

All three implementations share this interface.

HtmlTemplateParser (simple placeholder engine)

Replaces {{PropertyName}} tokens with property values serialized via ISerializer. Supports comment-based conditional blocks:

<p>Hello {{Name}}!</p>

<p>{{Address}}</p>

ISerializer jsonSerializer = new JsonSerializer();
string template = "<p>Hello {{Name}}!</p>";

var parser = new HtmlTemplateParser(jsonSerializer);
string html = await parser.Parse(template, new { Name = "Alice", Address = "123 Main St", showAddress = true });

RazorEngineCore

Full Razor syntax. Strips @model directives and Layout blocks (not supported by the engine). Best for simple templates without layout inheritance.

string razorTemplate = "<p>Hello @Model.Name</p>";
var model = new { Name = "Alice" };

IHtmlParser parser = new Regira.Web.HTML.RazorEngineCore.RazorTemplateParser();
string html = await parser.Parse(razorTemplate, model);

RazorLight

Lighter alternative with memory caching. Supports a TemplateKey option for cache reuse.

string razorTemplate = "<p>Hello @Model.Name</p>";
var model = new { Name = "Alice" };

IHtmlParser parser = new Regira.Web.HTML.RazorLight.RazorTemplateParser(new()
{
    TemplateKey = "invoice-template"   // reuse compiled template across calls
});
string html = await parser.Parse(razorTemplate, model);

Common.Web Utilities

GlobalExceptionHandlingMiddleware

Catches unhandled exceptions and logs them without exposing internals to the caller.

var builder = WebApplication.CreateBuilder();
builder.Services.AddGlobalExceptionHandling();

var app = builder.Build();
app.UseGlobalExceptionHandling();

RequestCultureMiddleware

Sets CultureInfo.CurrentCulture from a culture route value or query parameter.

var app = WebApplication.Create();
app.UseRequestCulture();
// Request: GET /api/products?culture=nl-BE  → sets nl-BE culture

RoutePrefixConvention

Apply a central route prefix to every controller.

var services = new ServiceCollection();
services.AddControllers(options =>
    options.UseCentralRoutePrefix(new RouteAttribute("api/v1")));

TextPlainInputFormatter

Enables [FromBody] string binding for text/plain requests.

var services = new ServiceCollection();
services.AddControllers(options =>
    options.InputFormatters.Insert(0, new TextPlainInputFormatter()));

ControllerExtensions

// Return INamedFile as a download or inline
return this.File(namedFile, inline: true);

RequestUtility

Extension methods on HttpRequest:

string  url     = Request.CurrentUrl();
Uri     baseUrl = Request.GetBaseUrl();
Uri     abs     = Request.GetAbsoluteUrl("/images/logo.png");
Uri?    referrer = Request.GetReferrer();
IPAddress? ip   = Request.GetIPAddress();

Web.Swagger

Add JWT Bearer and/or API Key inputs to the Swagger UI:

var builder = WebApplication.CreateBuilder();
builder.Services.AddSwaggerGen(o =>
{
    JwtAuthenticationExtensions.AddJwtAuthentication(o);
    // or
    ApiKeyAuthenticationExtensions.AddApiKeyAuthentication(o, parameterName: "X-Api-Key");
});

Make enums display as strings in Swagger:

var builder = WebApplication.CreateBuilder();
builder.Services.AddControllers().DisplayEnumAsString();

System.Hosting

WebHostOptions

Configure via appsettings.json under "Hosting":

Property Type Default Description
ServiceName string? null App / Windows Service display name
Mode string "Production" Hosting mode (inherited from HostOptions; see HostingModes)
LocalPort int? null Override listening port
SelfHosting bool false Flags the app as self-hosted (e.g. Kestrel / Windows Service)
EnableSwagger bool true Toggle Swagger UI
EnableCors bool false Toggle CORS
EnableHttps bool false Toggle HTTPS redirect
RoutePrefix string? null API route prefix
var builder = WebApplication.CreateBuilder();
builder.Host.UseWebHostOptions();

Background Tasks

Queue and execute long-running work without blocking requests.

services.UseBackgroundQueue();

// In a controller
public IActionResult StartExport([FromServices] IBackgroundTaskQueue queue)
{
    queue.QueueBackgroundWorkItem(async token =>
    {
        await GenerateReport(token);
    });
    return Accepted();
}

Typed tasks with progress tracking:

services.UseBackgroundQueue<ReportTask>();

// inject IBackgroundQueueManager<ReportTask>
var task = queueManager.Execute<string>(async (sp, t) =>
{
    t.SetProgress(0.5);
    return await GenerateReport(sp, t.Id);
});

Overview

  1. Index — Overview, template engines, middleware, Swagger, and hosting
  2. Examples — HTML templating, exception handling, background tasks

License

Apache License 2.0 — this package contains no license validation and no runtime limits. See LICENSE. A few companion packages are commercially licensed with a free tier; see the licensing overview.

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.  net9.0 was computed.  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 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 (5)

Showing the top 5 NuGet packages that depend on Regira.Web:

Package Downloads
Regira.Entities.Web

REST/CRUD Web API for Regira entities: EntityControllerBase controllers with list, search, filter, sort and paging endpoints. Top-level web entry point — brings the DependencyInjection and EF Core packages transitively. Free tier included — a license key removes the free-tier limits.

Regira.Web.Swagger

Swagger/OpenAPI documentation extensions using Swashbuckle for Regira.

Regira.Web.HTML.RazorLight

Razor-based HTML template rendering using RazorLight for Regira.

Regira.Security.Authentication.Web

ASP.NET Core authentication middleware and OpenAPI integration for Regira.

Regira.Web.HTML.RazorEngineCore

Razor-based HTML template rendering using RazorEngineCore for Regira.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.1.2 119 8/16/2026
6.1.1 160 8/12/2026
6.1.0 197 8/10/2026