The World’s First Source Code Demo for Pageless ASP.NET Web Forms Architecture

I have written two identical demo for MySqlExpress (an open source library of using MySQL in C#) which happens to be presented in Pageless ASP.NET Web Forms Architecture:

GitHub: https://github.com/adriancs2/MySqlExpress

This will be the first publicly available source demo of Pageless ASP.NET Web Forms Architecture.

The demo ships as two sibling projects — Demo_ASPNET_Pageless (Flat edition) and Demo_ASPNET_Pageless_Scoped (Scoped edition). Same application, same features, two ways of writing the request lifecycle. Readers can pick either one to start with; each project’s README cross-references the other.

My blog (adriancs.com) is also undergoing to be rebuilt in Pageless ASP.NET Architecture too. Stay tune. I will release the source code too once I finished it.

Core design of Pageless ASP.NET Architecture

The architecture rests on a few main pieces.

1. Web.config allows IIS response pass-through.

<system.webServer>
    <httpErrors existingResponse="PassThrough" />
</system.webServer>

This single setting tells IIS not to overwrite a handler’s response with its default error page. Without it, a request to / with no default document would never reach the application code.

2. Global.asax.cs is the routing table.

A switch statement inside Application_BeginRequest dispatches every URL to a static handler class. No attribute scanning, no assembly loading, no convention discovery — adding a route means adding a case.

3. A single template file provides the HTML frame.

SiteTemplate.cs holds the Header() and Footer() methods that every page calls. Layout lives in exactly one place; pages supply only their middle content.

4. Each route points at its own static handler class.

Handlers come in two flavours:

  • Page handlers — compose full HTML responses using StringBuilder and $@"..." interpolation.
  • API handlers — read form data, run SQL, write JSON responses.

Both flavours live side by side in engine/handlers/, one file per route. Each handler holds its SQL, its HTML, and its inline JavaScript in the same file, top to bottom.

5. CSS.

A single stylesheet (css/style.css), self-contained, no framework, no build step.

What the demo does not cover

Portable reusable JavaScript components. The demo keeps its JavaScript inline per handler, which suits its size but does not illustrate how to structure a shared component library.

Session state handling. In Pageless Architecture, session state must be handled manually. The IIS / framework built-in session state is unreliable in this mode because requests bypass the .aspx page lifecycle that normally triggers session activation. The recommended approach is a static dictionary, a MemoryCache, a cookie, or a database table — but the demo does not include any of these, because it has no state to track beyond the saved connection string.


Photo by Nii SHU on Unsplash