CodeBehind 4.5 Released; Advanced Async Capability

Published: (February 6, 2026 at 05:03 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Overview

Version 4.5 is the latest release of the CodeBehind framework built on .NET 7. The upcoming 4.6 version targets .NET 10 and is being developed by the Elanat team. This release rewrites the framework’s core to be fully asynchronous, delivering faster response times and a more responsive experience.

Elanat’s CodeBehind Framework is a full‑stack, open‑source (MIT‑licensed) framework for ASP.NET Core introduced in 2023. It combines the simplicity of Web Forms (using .aspx files and the Code‑Behind pattern) with the modern architecture of ASP.NET Core. By providing a stateless “WebForms Core” approach, it enables direct server‑side UI management, dynamic feature addition without recompilation, and reduced routing complexity—positioning it as a high‑performance alternative to the default ASP.NET frameworks.

Async Controller Configuration

1. Route‑Based Configuration

When using route‑based controllers, define actions as async Task methods:

public partial class Home : CodeBehindController
{
    public async Task PageLoad(HttpContext context)
    {
        // async logic here
    }
}

Add the middleware in Program.cs:

app.UseCodeBehindRouteAsync();

2. Default (ASPX‑Based) Configuration

For the default MVC view model based on .aspx pages, enable async processing by:

  1. Using the await keyword in the controller reference.
  2. Configuring the appropriate middleware.

Razor Syntax Example

@page
@controller await MyController

    ...

Standard ASPX Syntax Example

    ...

Add the middleware in Program.cs:

app.UseCodeBehindAsync();

Sample View (Razor)

@page
@controller await MyController

## Test Async

The @controller await MyController directive tells the framework to execute MyController asynchronously.

Sample Controller

using CodeBehind;

public partial class MyController : CodeBehindController
{
    public async Task PageLoad(HttpContext context)
    {
        string result = await DoSomethingAsync();
        Write(result);
    }

    private async Task DoSomethingAsync()
    {
        await Task.Delay(2000); // Simulate async work
        return "Hello CodeBehind! (after async work)";
    }
}
  • MyController inherits from CodeBehindController.
  • PageLoad is now async and returns a Task.
  • DoSomethingAsync simulates an asynchronous operation with a 2‑second delay and returns a string, which is written to the view.

Program.cs

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddCodeBehind();

var app = builder.Build();

app.UseCodeBehindAsync();   // Enables async handling for controllers

app.Run();
  • The CodeBehind service is registered via AddCodeBehind().
  • UseCodeBehindAsync() activates asynchronous controller processing.
  • The application starts with app.Run().

Benefits

CodeBehind 4.5 introduces full async support for both route‑based and ASPX‑based MVC controllers, improving responsiveness and overall performance. Developers can now implement asynchronous operations using await without adding extra complexity.

Resources

  • GitHub Repository:
  • NuGet Package:
  • Official CodeBehind Page:
Back to Blog

Related posts

Read more »