mcpbeat

Migrating Mvc Routing

microsoft/migrating-mvc-routing

> Converts ASP.NET MVC RouteCollection-based routing to ASP.NET Core endpoint routing with MapControllerRoute in Program.cs. Use when migrating RouteConfig.cs, RouteTable.Routes, routes.MapRoute, routes.MapMvcAttributeRoutes, or RouteCollection to ASP.NET Core. Also triggers for MVC routing upgrade, endpoint routing migration, and conventional route conversion.

1k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
17
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/microsoft/upgrade-agent-plugins --skill migrating-mvc-routing

The instruction itself

9 sections, as written by the author

ASP.NET MVC Routing Migration

Migrate ASP.NET MVC routing from RouteCollection/RouteConfig.cs to ASP.NET Core endpoint routing in Program.cs.

Workflow

Migration Progress:
- [ ] Step 1: Locate route registration
- [ ] Step 2: Convert to ASP.NET Core routing
- [ ] Step 3: Handle MVC + API controllers
- [ ] Step 4: Preserve existing customizations
- [ ] Step 5: Remove RouteConfig

Step 1: Locate Route Registration

Find all route registration code. Typically lives in RouteConfig.cs:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapMvcAttributeRoutes();
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Catalog", action = "Index", id = UrlParameter.Optional }
        );
    }
}

Step 2: Convert to ASP.NET Core Routing

Default routes (no customization): Replace with:

app.MapDefaultControllerRoute();

Custom routes: Add MapControllerRoute calls in Program.cs. Inline defaults and optional parameters into the pattern string because ASP.NET Core uses pattern tokens instead of a separate defaults object:

// Old: url: "{controller}/{action}/{id}", defaults: new { controller = "Catalog", action = "Index", id = UrlParameter.Optional }
// New:
app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Catalog}/{action=Index}/{id?}");
Route Pattern Conversion Reference

| Old (RouteCollection) | New (ASP.NET Core) |

|-----------------------|--------------------|

| url: "{controller}/{action}/{id}" | pattern: "{controller}/{action}/{id?}" |

| defaults: new { controller = "Home" } | pattern: "{controller=Home}" |

| defaults: new { action = "Index" } | pattern: "{action=Index}" |

| id = UrlParameter.Optional | {id?} |

| routes.MapMvcAttributeRoutes() | app.MapControllers() |

Step 3: Handle MVC + API Controllers

If the project has both MVC and API controllers, register both attribute and conventional routing. Call app.MapControllers() before app.MapControllerRoute() so attribute-routed API controllers take precedence over conventional routes — otherwise conventional routes could intercept API requests:

app.MapControllers(); // Attribute routing for API controllers
app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

Step 4: Preserve Existing Customizations

Keep any existing routing middleware on the application object and add new routes alongside it. Carry over method-chained customizations like .RequireSystemWebAdapterSession():

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}")
    .RequireSystemWebAdapterSession();

Step 5: Remove RouteConfig

  • Delete RouteConfig.cs (or equivalent file containing RegisterRoutes). Only delete if it contains no non-routing logic.
  • Remove all references to RouteTable.Routes across the codebase.
  • Clean up orphaned using statements and class references.

Success Criteria

  • All routes migrated to Program.cs with correct pattern syntax
  • Both attribute and conventional routing configured when needed
  • RouteConfig.cs removed and no RouteTable.Routes references remain
  • Project builds without errors

How to use it

Copy the folder

Take microsoft/migrating-mvc-routing from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.