Skip to content

Add dotnet global tool for converting ASP.NET Web Forms (.ascx) to Blazor (.razor)#328

Draft
Copilot wants to merge 6 commits intodevfrom
copilot/add-ascx-to-razor-tool
Draft

Add dotnet global tool for converting ASP.NET Web Forms (.ascx) to Blazor (.razor)#328
Copilot wants to merge 6 commits intodevfrom
copilot/add-ascx-to-razor-tool

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

Implements a CLI tool to automate conversion of Web Forms user controls to Blazor Razor components, addressing the need for migration tooling alongside the component library.

Implementation

New Project: src/BlazorWebFormsComponents.Cli/

  • Packaged as dotnet global tool: WebformsToBlazor.Cli
  • Command: webforms-to-blazor
  • Built on System.CommandLine for argument parsing

Conversions Performed

Web Forms Syntax Blazor Output
<%@ Control ... Inherits="X" %> @inherits X
<asp:Button> <Button>
runat="server" (removed)
<%: expr %>, <%= expr %>, <%# expr %> @(expr)
<% code %> @{ code }
Item.Property context.Property (in expressions only)

Usage

# Install
dotnet tool install --global WebformsToBlazor.Cli

# Convert single file
webforms-to-blazor -i MyControl.ascx

# Convert directory recursively
webforms-to-blazor -i ./Controls -r -f

Example

Input (ProductCard.ascx):

<%@ Control Language="C#" Inherits="MyApp.ProductCard" %>
<asp:Image ImageUrl='<%# Item.ImageUrl %>' runat="server" />
<asp:Button Text="Add to Cart" OnClick="Handler" runat="server" />

Output (ProductCard.razor):

@inherits MyApp.ProductCard

<Image ImageUrl='@(context.ImageUrl)' />
<Button Text="Add to Cart" OnClick="Handler" />

Future Extension Point

AiAssistant class provides hook for AI-powered enhancement via GitHub Copilot SDK/OpenAI (currently no-op).

Documentation

  • src/BlazorWebFormsComponents.Cli/README.md - Full usage guide
  • src/BlazorWebFormsComponents.Cli/EXAMPLES.md - Conversion examples
  • Root README.md - Tool overview and installation
Original prompt

This section details on the original issue you should resolve

<issue_title>Suggestion: dotnet global tool to convert ascx to razor</issue_title>
<issue_description>It would be a great companion tool to have to convert ascx files to razor components - fixing any obvious name changes along the way (thinking the @context vs Item problem here)</issue_description>

<agent_instructions>Let's start a companion project in the solution in this repository for a command-line tool that helps facilitate this conversion using both the BlazorWebFormsComponents and the GitHub Copilot SDK
</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@csharpfritz I love this idea, and it is a big rock to be addressed as a future project on its own. Perhaps as part of a larger collection of tools that augment the Blazor conversion of applications

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 1, 2026 03:11
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add dotnet global tool to convert ascx to razor components Add dotnet global tool for converting ASP.NET Web Forms (.ascx) to Blazor (.razor) Feb 1, 2026
Copilot AI requested a review from csharpfritz February 1, 2026 03:22
@csharpfritz
Copy link
Collaborator

@copilot I want the name of the CLI app to be WebformsToBlazor. The name Fritz shouldn't appear in the app name

…r.Cli

Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 1, 2026

@copilot I want the name of the CLI app to be WebformsToBlazor. The name Fritz shouldn't appear in the app name

Done! Renamed the package from Fritz.WebFormsToBlazor.Cli to WebformsToBlazor.Cli. Updated in the project file and all documentation. (commit c2c9447)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion: dotnet global tool to convert ascx to razor

2 participants