Created
July 10, 2021 18:18
-
-
Save dima-iholkin/38f9ee325668f50d9ff9fea13934f229 to your computer and use it in GitHub Desktop.
ASP.NET Core introspect the app's registered routes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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