The goal of this project is to explore building some of the basic building blocks of the WebForms on ASP.NET Core. This will isolate out the actual components needed to build a functional page.
Supported so far:
System.Web.IHttpHandler
System.Web.UI.Page
System.Web.UI.HtmlTextWriter
System.Web.UI.HtmlControls.*
System.Web.UI.WebControls.*
System.Web.Routing.*
- Master pages
- Compilation of
aspx
pages (both VB and C#) - Binary compatibility (via the
WebForms.SystemWebShim
package) - limited support; needs testing
What is NOT supported:
- Designer support
System.Web
hosting modelSystem.Web
membership model- Any
System.Web
concept not called out as in scope
This will make use of Microsoft.AspNetCore.SystemWebAdapters
to provide the System.Web.HttpContext
that is at the core of the WebForms pipeline.
WebForms
- Contains the majority of the page/control/etc methods required for WebFormsWebForms.Compiler
- Build time compiler that will generate a.dll
for each page in the project. This includes a Roslyn code generator that can generate a strongly-type file to include the compiled assemblies that will remove the need for runtime reflection to load them.WebForms.Compiler.Dynamic
- Run time compiler that will allow for updatingaspx
at run time and generating a new in-memory assemblyWebForms.HttpHandler
- ContainsIHttpHandler
and related helpers to enable hooking them up to ASP.NET CoreWebForms.Routing
- Contains APIs from theSystem.Web.Routing
namespaceWebForms.Extensions
- Contains APIs from theSystem.Web.Extensions
namespaceWebForms.SystemWebShim
- A package with aSystem.Web.dll
assembly that will type forward to the new locations. This is build for .NET 6+ and would help with controls/assemblies/etc that are compiled and cannot be recompiled for some reason. If they use members/types not supported, they will throw at runtime, but can be a helpful step in migrating old projects (see theTypeDumper
tool to regenerate the available types for the shim)
-
Add a
nuget.config
or update yours to have the ci feed:<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <!--To inherit the global NuGet package sources remove the <clear/> line below --> <clear /> <add key="nuget" value="https://api.nuget.org/v3/index.json" /> <add key="webforms" value="https://webformsfeed.blob.core.windows.net/feed/index.json" /> </packageSources> </configuration>
-
Add
WebForms
andWebForms.Compiler
to your project -
Add WebForms to your services (this automatically will add the System.Web adapters - this can be configured independently if needed)
builder.Services.AddWebForms() .AddCompiledPages(); builder.Services.AddSession(); builder.Services.AddDistributedMemoryCache();
-
Add the System.Web middleware and map the webforms pages:
... app.UseSession(); app.UseSystemWebAdapters(); ... app.MapWebForms();
-
Add any
.aspx
or.aspx.cs
/.aspx.vb
files to your project. They should be served up as expected when you run.
There is a dynamic compilation method that can be enabled by doing the following (continued from the above sample):
-
Add
WebForms.Compiler.Dynamic
andWebForms.Compiler
-
Add
<EnableRuntimeAspxCompilation>true</EnableRuntimeAspxCompilation>
to a property group in the project file -
Add dynamic compilation to the services:
builder.Services.AddWebForms() .AddDynamicPages();
Please see the design docs to see the designs and plans for how this are expected to work.