Netiqo Framework

Complete documentation for the self-hosted .NET micro-framework

← Back to Main Site

🚀 Quick Start

Create your first self-hosted web server in minutes

Program.cs
using Netiqo.Framework;

var host = new Host("127.0.0.1", 8080);
host.LogMessage += Console.WriteLine;

host.RegisterRoute(new Route("/", Request.HttpMethod.GET, 
    htmlResponse: "<h1>Homepage</h1>"));

await host.StartAsync();

📍 Framework Structure

Main components and API for development

Host Class

Main class for web server management with optional HTTPS support.

Host Constructor
public Host(string ip, int port, string certPath = null, string certPassword = null)

Route Class

Route definition with support for dynamic handlers or static HTML responses.

Route Constructor
public Route(string path, Request.HttpMethod method, 
    Func<string, Task<string>> handler = null, 
    string htmlResponse = null)

RouteAttribute

Decorator for defining routes directly on methods of controller classes.

Route Attribute Example
[Route("/api/test", Request.HttpMethod.GET)]
public string Test(string body) => "<h1>Test</h1>";

HttpMethod Support

Full support for all standard HTTP methods:

  • GET, POST, PUT, DELETE
  • PATCH, HEAD, TRACE
  • OPTIONS, CONNECT

Device Class

Utility to obtain network information and default configurations.

Device Utilities
string ip = Device.Ipv4();
int defaultPort = Device.DefaultPort; // 8080

🔍 Dynamic and Static Routing

Maximum flexibility in route definition

Static HTML

Perfect for informational pages or content that does not change frequently.

Static HTML Route
host.RegisterRoute(new Route("/about", Request.HttpMethod.GET, 
    htmlResponse: "<h1>About Us</h1>"));

Dynamic Handler

For content that requires server-side processing and interaction with data.

Dynamic Handler
host.RegisterRoute(new Route("/login", Request.HttpMethod.POST, async body =>
{
    var parsed = HttpUtility.ParseQueryString(body);
    return $"<h1>Welcome {parsed["username"]}</h1>";
}));

Configuration from JSON

Load routes from external JSON files for more flexible management.

routes.json
[
  {
    "Path": "/hello",
    "Method": "GET",
    "HtmlResponse": "<h1>Hello from JSON</h1>"
  }
]

🔐 HTTPS Support

Secure connections with SSL/TLS certificates

Easily configure secure connections using PFX certificates for production environments.

HTTPS Configuration
var host = new Host("127.0.0.1", 443, 
    "certificates/mysite.pfx", "mypassword");

📃 Static Files

Automatic service of static resources

The files in the wwwroot/ are automatically served by the server, allowing you to distribute CSS, JavaScript, images and other assets needed by your application.

Folder structure
📁 Project/
├── 📁 wwwroot/
│   ├── 📁 css/
│   │   └── styles.css
│   ├── 📁 js/
│   │   └── app.js
│   └── 📁 images/
│       └── logo.png
└── Program.cs

📅 Events and Logging

Flexible and customizable logging system

Flexible logging system to intercept and manage all server events.

Event Logging
host.LogMessage += msg => Console.WriteLine("[LOG] " + msg);

// Advanced logging with timestamps
host.LogMessage += msg => {
    var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
    Console.WriteLine($"[{timestamp}] {msg}");
};

📂 Deployment Scenarios

Versatile for all kinds of applications

💻

Embedded Applications

Integrate web servers directly into your desktop or IoT applications

🏠

Local Backend

Create APIs and services accessible from the local network without complex configurations

🔧

Microservices

Develops lightweight microservices for distributed architectures