Routeslist
v1.1.2.1
RoutesList是一种方便的工具,可让您以清晰简洁的方式查看.NET应用程序中的所有路由。您可以轻松地检查路线的方法,URI,控制器,操作和中间件,并自定义输出以适应您的需求。 RouteSlist与.NET Core App 3.1,.NET5.0,.NET 6,.NET7.0,Razor Pages,ASP.NET MVC和Blazor Server Projects一起使用。
兼容:




来自nuget.org
Install-Package RoutesList 只需添加services.AddRoutesList到服务配置方法。
例子:
startup.cs
\ .. .
public void ConfigureServices ( IServiceCollection services )
{
\ .. .
services . AddRoutesList ( ) ;
}并添加到配置方法
例子:
startup.cs
\ .. .
public void Configure (
IApplicationBuilder app ,
IWebHostEnvironment env ,
)
{
\ .. .
app . UseRoutesList ( ) ;
}默认端点: http://your_application_address/routes
例子:
program.cs
using RoutesList . Gen ;
var builder = WebApplication . CreateBuilder ( args ) ;
// Add services to the container.
builder . Services . AddRazorPages ( ) ;
builder . Services . AddRoutesList ( ) ; < -- usage
var app = builder . Build ( ) ;
// Configure the HTTP request pipeline.
if ( ! app . Environment . IsDevelopment ( ) ) {
app . UseExceptionHandler ( "/Error" ) ;
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app . UseHsts ( ) ;
}
app . UseHttpsRedirection ( ) ;
app . UseStaticFiles ( ) ;
app . UseRouting ( ) ;
app . UseAuthorization ( ) ;
app . MapRazorPages ( ) ;
app . UseRoutesList ( ) ; < -- usage
app . Run ( ) ;
public partial class Program { } public class Program
{
public static void Main ( string [ ] args )
{
var builder = WebApplication . CreateBuilder ( args ) ;
// Add services to the container.
builder . Services . AddRazorPages ( ) ;
builder . Services . AddServerSideBlazor ( ) ;
builder . Services . AddSingleton < WeatherForecastService > ( ) ;
builder . Services . AddRoutesList ( ) ;
var app = builder . Build ( ) ;
// Configure the HTTP request pipeline.
if ( ! app . Environment . IsDevelopment ( ) ) {
app . UseExceptionHandler ( "/Error" ) ;
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app . UseHsts ( ) ;
}
app . UseHttpsRedirection ( ) ;
app . UseStaticFiles ( ) ;
app . UseRouting ( ) ;
app . MapBlazorHub ( ) ;
app . MapFallbackToPage ( "/_Host" ) ;
app . UseRoutesList ( options => {
options . SetAppAssembly ( typeof ( Program ) . Assembly ) ; < -- setup current application webassembly with blazor component
} ) ;
app . Run ( ) ;
}
} 在app.userouteslist中,您可以通过选项
| 姓名 | 描述 |
|---|---|
| 端点 | 端点名称 |
| 标题 | 网站的标题 |
| SettableClasses | 为表添加模板类 |
| SetAppAssembly | 将当前的应用程序组件与大麻组件一起设置 |
startup.cs
public void Configure (
IApplicationBuilder app ,
IWebHostEnvironment env ,
)
{
IDictionary < string , string [ ] > dict = new Dictionary < string , string [ ] > ( ) ;
string [ ] classes = dict [ "table" ] = new string [ 2 ] { "table" , "table-striped" } ;
app . UseRoutesList ( options => {
options . Endpoint = "your_new_endpoints" ;
options . Tittle = "Your new Title for site" ;
options . SetTableClasses ( classes ) ;
options . SetAppAssembly ( typeof ( Program ) . Assembly )
} ) ;
}program.cs
var builder = WebApplication . CreateBuilder ( args ) ;
// Add services to the container.
builder . Services . AddRazorPages ( ) ;
builder . Services . AddControllersWithViews ( ) ;
var app = builder . Build ( ) ;
// Configure the HTTP request pipeline.
if ( ! app . Environment . IsDevelopment ( ) )
{
app . UseExceptionHandler ( "/Error" ) ;
app . UseHsts ( ) ;
}
app . UseHttpsRedirection ( ) ;
app . UseStaticFiles ( ) ;
app . UseAuthorization ( ) ;
app . MapGet ( "/hi" , ( ) => "Hello!" ) ;
app . MapDefaultControllerRoute ( ) ;
app . MapRazorPages ( ) ;
app . UseRoutesList ( options => {
options . Endpoint = "your_new_endpoints" ;
options . Tittle = "Your new Title for site" ;
options . SetTableClasses ( classes ) ;
options . SetAppAssembly ( typeof ( Program ) . Assembly )
} ) ;
app . Run ( ) ; 始终欢迎贡献,无论是添加/建议新功能,错误修复,记录新文件格式还是简单地编辑一些语法。为此,创建新的github问题并描述您的问题,并为错误/增强添加问题标签