ASP.NET Core  

WebForms Core on NuGet: Redefining Server-Driven DOM for Modern .NET

From Legacy Constraints to Modern Revival

In the past, Microsoft WebForms was a system that offered only limited and inefficient patterns. Structural weaknesses, heavy dependency on ViewState, poor performance, and lack of flexibility forced many developers and businesses to migrate their systems to MVC, Razor Pages, Blazor , and even Minimal API .

These migrations primarily occurred because Microsoft failed to present any clear roadmap for improving and modernizing classic WebForms.

However, in 2024 , the Elanat introduced WebForms Core —a completely new approach that not only distanced itself from the weaknesses of classic WebForms but also redefined its concept with modern web architecture.

Initially introduced as one of the core capabilities of the CodeBehind framework, this technology rapidly gained traction due to its standalone design and flexibility, becoming implementable and executable in various popular programming languages .

Today, Elanat has released WebForms Core as a standalone package on NuGet , enabling direct usage in .NET projects including MVC, Razor Pages, and Minimal API.

Package link:

https://www.nuget.org/packages/WFC

WebForms Core: Neither a "Return to WebForms" Nor a "Blazor Competitor"

What WebForms Core Is NOT:

  • NOT a revival of classic WebForms – No ViewState, no page lifecycle complexities

  • NOT a Blazor alternative – Different architecture, different use cases

  • NOT another JavaScript framework – Server-first, JavaScript-light approach

  • NOT tied to specific UI patterns – Works with MVC, Razor Pages, and Minimal API

What WebForms Core IS:

  • A serious server-centric DOM platform in the .NET ecosystem

  • A modern architectural alternative for server-driven DOM control

  • A bridge between backend logic and frontend interactions

  • A performance-optimized , modern approach to full-stack development

Architectural Innovation: How WebForms Core Works

The Core Principle

WebForms Core operates on a simple yet powerful principle: Server controls DOM, Client renders efficiently .

Server-side (.NET)

WebForms form = new WebForms();

form.SetValue("username", "JohnDoe");
form.SetBackgroundColor("<main>", "lightblue");
form.SetGetEvent("btnSubmit", "onclick", "/api/submit");

return form.Response();

Result

[web-forms]
svusername=JohnDoe
bc<main>=lightblue
EgbtnSubmit=onclick|/api/submit

The client-side WebFormsJS library (just 40KB after Minify + Gzip) interprets these commands and applies them to the DOM with surgical precision.

Key Technical Innovations

  1. Lightweight Protocol : Uses a simple INI-Like protocol instead of heavy JSON/XML

  2. Intelligent DOM Targeting : Advanced selectors for precise element manipulation

  3. Built-in Real-time : SSE and WebSocket support out of the box

  4. Automatic Optimization : Only changed data is transmitted

  5. No JavaScript Fatigue : Minimal client-side code required (Close to zero)

Why .NET Developers Should Pay Attention

For Backend-Focused Teams

WebForms Core addresses a critical pain point: backend developers can now build interactive UIs without deep frontend expertise .

Traditional approach: Backend API + Frontend Framework

[ApiController]
public class UserController : ControllerBase
{
    [HttpPost("update")]
    public IActionResult UpdateUser(UserDto user)
    {
        // Backend only - frontend needs separate implementation
        return Ok(new { success = true });
    }
}

WebForms Core approach: Unified control

public class UserController : Controller
{
    public IActionResult UpdateUser(UserDto user)
    {
        WebForms form = new WebForms();

        form.SetValue("displayName", user.Name);
        form.Message("User updated successfully", "success");
        form.SetDisabled("btnSubmit", true);

        return Content(form.Response(), "text/plain");
    }
}

Performance Advantages

MetricTraditional SPA (React/Vue/Angular)WebForms CoreAdvantage
Initial Load200-500KB JS45KB JS4-10x lighter
Time to Interactive2-5 seconds<1 second2-5x faster
Backend ComplexityHigh (API design)Low (direct control)Simpler architecture
Frontend ComplexityHigh (state management)MinimalReduced cognitive load

WebForms Core loads only a single lightweight library on the client’s first request, whereas traditional SPAs typically require downloading multiple, often large, JavaScript libraries.

Actual performance may vary depending on application complexity and deployment environment.

Seamless Integration with Existing .NET Projects

Add Package

<!-- Add to your .NET project -->
<PackageReference Include="WFC" Version="2.0.0" />

Access to NameSpase

using WebFormsCore;

Use with Minimal API

app.MapPost("/submit", async (HttpContext context) =>
{
    WebForms form = new WebForms();

    // Process form data
    var name = context.Request.Form["name"];

    // Update UI directly
    form.SetText("result", $"Hello, {name}!");
    form.SetBackgroundColor("result", "lightgreen");

    return form.Response();
});

Use with MVC

public class HomeController : Controller
{
    public IActionResult Index()
    {
        WebForms form = new WebForms();

        form.SetGetEventListener("loadData", "click", "/api/data");
        ViewBag.WebForms = form.ExportToHtmlComment();

        return View();
    }
}

Use with Razor Pages

public class ContactModel : PageModel
{
    public IActionResult OnPost()
    {
        WebForms form = new WebForms();

        form.Message("Thank you for your message!", "success");
        form.CallSSEBack("/api/sse/event1");

        return Content(form.Response());
    }
}

WebForms Core Architecture

WebForms Core revolutionizes web development through a clean Commander-Executor architecture where the server acts as Commander—defining logic, events, and DOM changes—while the lightweight WebFormsJS library (just 40KB) serves as pure Executor on the client. This stateless server approach sends concise INI-formatted commands that enable direct DOM manipulation without page reloads, working seamlessly with MVC, Razor Pages, or Minimal API while maintaining full HTML standards compliance.

Unlike traditional frameworks, WebForms Core eliminates JavaScript fatigue by letting backend developers build interactive UIs using their existing skills. It supports real-time features like SSE and WebSocket natively, offers offline capabilities through Service Worker integration, and even allows client-side execution without a server.

This architecture is even suitable for games

  • ✔️ WebForms Core can create dynamic, game-like, real-time UI

  • ✔️ Can create animations with CSS + DOM + timer + event

  • ✔️ Latency is acceptable for this style of interaction

  • ✔️ Even game logic can be server-driven

However, Not ideal for frame-critical, high-frequency rendering scenarios such as canvas, WebGL, or GPU-driven animations.

To better understand where WebForms Core fits within the .NET ecosystem, the following comparison highlights practical trade-offs across common UI technologies.

Comparison with Other .NET UI Technologies

Comparison assumption: Standard web projects (Admin, LOB, Enterprise, MVP)

FeatureBlazorRazor Pages & MVCWebForms Core
Architecture ModelComponent-based, state-drivenTraditional request/responseServer-driven DOM (command-based)
DOM ControlIndirect (via component state)Manual or JavaScript-basedDirect, declarative from server
JavaScript DependencyMinimal (framework handles)Extensive (developer controlled)40KB fixed runtime
Learning Curve (Backend Devs)ModerateLowVery Low
Development Speed (Backend Team)MediumFastVery Fast
Frontend Skill RequiredModerateHighMinimal
Real-time SupportSignalR requiredManualBuilt-in (SSE + WebSocket)
Offline CapabilitiesLimitedNoneAdvanced (Service Worker)
Performance (UI Updates)Good (circuit chatter)Implementation dependentLightweight (commands)
Initial Load SizeWASM: Large / Server: MediumSmallVery Small
SEO & HTML StandardsMedium (mode dependent)ExcellentExcellent (HTML-native)
Testing (UI Logic)Specialized tools neededJS testing requiredCommand-level testable
Scalability (Server)Server: Circuit limitsExcellentExcellent (stateless)
Legacy IntegrationChallengingGoodExcellent
Best ForRich interactive applicationsContent-heavy, SEO-first sitesAdmin panels, rapid development, legacy modernization

Getting Started with WebForms Core in .NET

Step 1 : Install the Package

dotnet add package WFC

Step 2 : Add WebFormsJS to Your Layout

<!DOCTYPE html>
<html>
<head>
+   <script type="module" src="/script/web-forms.js"></script>
</head>
<body>
    <main>
        @RenderBody()
    </main>
</body>
</html>

Get the WebFormsJS module from this repository: https://github.com/webforms-core/Web_forms

Step 3 : Start Using in Your Controllers

using WebFormsCore;

public class InteractiveController : Controller
{
    public IActionResult DynamicForm()
    {
        WebForms form = new WebForms();

        // Build interactive UI from server
        form.AddTag("<main>", "form", "userForm");
        form.AddTag("userForm", "input", "username");
        form.SetGetEvent("username", "onchange", "/api/validate");

        return Content(form.Response());
    }
}

Step 4 : Explore Advanced Features

// Progressive enhancement
public IActionResult EnhancedExperience()
{
    WebForms form = new WebForms();

    // Conditional UI based on capabilities
    form.IsMatchMedia("(max-width: 768px)");
    form.StartBracket();
    form.SetClass("myMenu", "mobile-menu");
    form.EndBracket();

    // Async data loading
    form.Async();
    form.AddText("content", Fetch.LoadUrl("/api/content"));

    return Content(form.Response());
}

Step 5 : Even Service Worker is Available

[HttpGet("/masterpages")]
public string MasterPage()
{
    WebForms form = new WebForms();

    form.ServiceWorkerRegister("/service-worker.js", "/masterpages");
    form.ServiceWorkerRouteAlias("/masterpages/*", "/masterpages/layout");

    form.SetMasterPagesEvent("<body>", HtmlEvent.OnLoad, "<main>");

    Response.Headers["Cache-Control"] = "public,max-age=31536000";

    return form.Response();
}

Security Model and Developer Control

WebForms Core adopts a security-by-configuration approach that balances flexibility with protection.

On the client side, the WebFormsJS module exposes a set of explicit security options that allow developers to restrict or completely disable potentially dangerous behaviors such as dynamic code evaluation, JavaScript injection, module loading, and method invocation

// Security configuration example
WebFormsOptions.DisableEval = false;
WebFormsOptions.DisableAppendJavaScriptTag = false;
WebFormsOptions.DisableLoadModule = false;

WebFormsOptions.UseLoadModulePathOnlyInAcceptedList = false;
WebFormsOptions.LoadModulePathOnlyInAcceptedList = ["math"];

WebFormsOptions.DisableCallMethod = false;
WebFormsOptions.UseCallMethodOnlyInAcceptedList = false;
WebFormsOptions.CallMethodOnlyInAcceptedList = ["alert"];

WebFormsOptions.DisableCallModuleMethod = false;
WebFormsOptions.UseCallModuleMethodOnlyInAcceptedList = false;
WebFormsOptions.CallModuleMethodOnlyInAcceptedList = ["confirm"];

WebFormsOptions.SendChecksum = false;
WebFormsOptions.ChecksumName = "checksum";

These options allow teams to significantly reduce XSS attack surfaces by limiting executable behaviors to an explicit allowlist.

In security-sensitive environments, dynamic execution can be fully disabled, making the client runtime operate as a strict command executor rather than a script interpreter.

Form submission and user input validation can be performed both on the server and the client using built-in validation methods such as IsRegexMatch, IsRegexNotMatch, Include, and NotInclude, enabling consistent validation rules across layers.

Ultimately, WebForms Core intentionally places security responsibility in the hands of developers, making trust boundaries explicit and configurable rather than hidden behind opaque abstractions.

Standard CSRF protections provided by the hosting framework (ASP.NET MVC, Razor Pages, Minimal API) remain fully applicable.

Note: Since WebForms Core performs direct DOM manipulation based on HTML structure, developers must explicitly configure and enforce security controls.

The Future of Server-Driven Development in .NET

Why This Matters Now

  1. Developer Productivity : Backend teams can deliver full-stack solutions

  2. Performance : Lightweight approach beats heavy JavaScript frameworks

  3. Maintainability : Single codebase reduces bugs and complexity

  4. Modern Features : Real-time, offline, testing built-in

Where WebForms Core Excels

  • Internal Business Applications

  • Admin Panels and Dashboards

  • Rapid Prototyping and MVPs

  • Legacy System Modernization

  • Mobile-Optimized Web Applications

WebForms Core addresses a variety of web development problems by providing a different approach. It is the hybrid innovation in the web development; a serious, production-ready solution for server-based DOM manipulation.

Note: WebForms Core technology is available for over 30 programming languages ​​and is not exclusive to the .NET ecosystem.

The server part classes of this technology are maintained in the following repository: https://github.com/webforms-core/Web_forms_classes

Conclusion: A New Paradigm for .NET Web Development

WebForms Core on NuGet represents more than just another UI library—it's a fundamental rethinking of how server-side code can and should interact with client-side interfaces.

For .NET developers tired of JavaScript framework churn, for teams wanting to leverage existing backend expertise, for projects needing performance without complexity—WebForms Core offers a compelling alternative.

It's not about going back to the old ways. It's about moving forward with a modern, efficient, and practical approach to building web applications in the .NET ecosystem.

Key Takeaway : WebForms Core proves that server-driven development can be modern, performant, and developer-friendly. It's not just viable—it's advantageous for a wide range of real-world applications.