Modular Structure in CodeBehind

Published: (February 20, 2026 at 06:30 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

What is CodeBehind?

CodeBehind is a powerful backend framework built on years of experience with ASP.NET WebForms from Microsoft. Developed by Elanat, it targets the latest .NET versions (currently .NET 10).

CodeBehind’s Modular Structure

By default, CodeBehind provides a revolutionary modular structure. You can copy and paste an ASPX file together with its compiled DLL from another project into a live web system without rebuilding or republishing the entire project.

Modular Structure in .NET

This gives developers a vanilla PHP‑like experience in a compiled .NET environment: lightweight, flexible, and fast. Any project built with CodeBehind is inherently modular.

How to Create a New Module

You can copy either an ASPX file (view) or a DLL (controller). The two scenarios are described below.

Example 1: View Only

In WebForms Core, a view can exist without a controller, meaning a single ASPX file can be a module.

random.aspx

@page
@layout "/layout.aspx"
@{
    // Generate a random number between 1 and 100
    var rnd = new Random();
    int number = rnd.Next(1, 101);

    // Generate a message based on the number
    string message = number > 50 ? "The number is big!" : "The number is small!";
}

## Random Number Generator in CodeBehind

Your random number: **@number**

Message: *@message*

@for (int i = 0; i 
    An "About Us" page provides information about a company, organization, or individual. 
    It tells the brand’s story, shares its vision, history, and values, introduces the team, 
    and builds trust with users.

Step 5 – Add a controller

using CodeBehind;

namespace ModuleProject
{
    public partial class AboutController : CodeBehindController
    {
        public void PageLoad(HttpContext context)
        {
            ViewData.Add("title", "About page");
        }
    }
}

Step 6 – Publish the project

Deploy the module by:

  1. Copying Default.aspx to wwwroot/about in the live project.
  2. Copying the compiled DLL to wwwroot/bin.

Then trigger recompilation:

SetCodeBehind.CodeBehindCompiler.ReCompile();

Your new module becomes active without rebuilding the main project, demonstrating the true modularity of CodeBehind.

  • CodeBehind on GitHub:
  • CodeBehind on NuGet:
  • CodeBehind page:
0 views
Back to Blog

Related posts

Read more »

lazygit-style TUI for NuGet

!Cover image for lazygit-style TUI for NuGethttps://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-up...