Skip to content

Instantly share code, notes, and snippets.

@waf
Created February 22, 2026 05:51
Show Gist options
  • Select an option

  • Save waf/3be743139e40f1024cd36abd98aa5b83 to your computer and use it in GitHub Desktop.

Select an option

Save waf/3be743139e40f1024cd36abd98aa5b83 to your computer and use it in GitHub Desktop.
System Web Adapters + ASP.NET Areas + MapReverseProxy

If running into a problem where you have multiple areas registered in an MVC ASP.NET Framework app, and you're trying to port this to ASP.NET Core MVC (using System Web Adapters and/or YARP), you may find that while the application with a single area works, multiple areas do not work (only the first area registration works).

The fix is to update your MapReverseProxy line to the following:

app.MapReverseProxy()
   .Add(static builder => ((RouteEndpointBuilder)builder).Order = int.MaxValue);

Or, if you're using MapForwarder:

app.MapForwarder("/{**catch-all}", app.Configuration["ProxyTo"])
   .Add(static builder => ((RouteEndpointBuilder)builder).Order = int.MaxValue);

I think that multiple calls to MapAreaControllerRoute (or MapControllerRoute with constraints) must increment the order of the middleware. By explicitly setting the YARP proxy to int.MaxValue, we ensure that it's last, and interleaved with the MapAreaControllerRoute.

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