Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dima-iholkin/38f9ee325668f50d9ff9fea13934f229 to your computer and use it in GitHub Desktop.
Save dima-iholkin/38f9ee325668f50d9ff9fea13934f229 to your computer and use it in GitHub Desktop.
ASP.NET Core introspect the app's registered routes.
// in Startup.cs
using Microsoft.AspNetCore.Mvc.Infrastructure;
using IdentityServer4.Hosting;
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
using (var scope = app.ApplicationServices.CreateScope())
{
var _obj = scope.ServiceProvider.GetRequiredService<IActionDescriptorCollectionProvider>();
var _obj1 = _obj.ActionDescriptors.Items;
// get the app's registered routes.
var _obj2 = scope.ServiceProvider.GetRequiredService<IEnumerable<Endpoint>>();
// get the IdentityServer's registered WebAPI endpoints.
// but there are probably also some RazorPages or MVC pages registered somewhere else,
// need to find them.
}
// continues with the usual stuff ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment