EasyAdminBlazor 2.3.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyAdminBlazor --version 2.3.1
                    
NuGet\Install-Package EasyAdminBlazor -Version 2.3.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasyAdminBlazor" Version="2.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyAdminBlazor" Version="2.3.1" />
                    
Directory.Packages.props
<PackageReference Include="EasyAdminBlazor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EasyAdminBlazor --version 2.3.1
                    
#r "nuget: EasyAdminBlazor, 2.3.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EasyAdminBlazor@2.3.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EasyAdminBlazor&version=2.3.1
                    
Install as a Cake Addin
#tool nuget:?package=EasyAdminBlazor&version=2.3.1
                    
Install as a Cake Tool

🚀 快速开始

环境要求

  • .NET 10 SDK
  • 数据库:模板默认使用 SQLite,零配置即可跑起来;生产环境再切换到 MySQL、SQL Server、PostgreSQL 等 FreeSql 支持的数据库
  • (可选)Redis(聊天、分布式缓存等扩展功能需要)

全新项目

要是从零开始,直接用模板创建项目最省事:

# 安装模板包
dotnet new install EasyAdminBlazor.Templates

# 用模板创建项目
dotnet new easyadmin -n MyProjectName

# 进到项目目录直接跑起来
cd MyProjectName
dotnet run

运行后打开后台登录页:http://localhost:端口/admin/i4ByMAX4(i4ByMAX4 是默认的 AdminRouteSecret 安全码,端口以控制台启动日志里的监听地址为准)。默认账号 admin,密码 123yyq。

现有项目

如果项目已经存在,那就手动安装配置,照着下面几步走就行。

第一步:安装 NuGet 包

# 核心包(必须)
dotnet add package EasyAdminBlazor

# 数据库支持(根据你的数据库选择其中一个)
dotnet add package FreeSql.Provider.MySqlConnector      # MySQL
dotnet add package FreeSql.Provider.SqlServer  # SQL Server
dotnet add package FreeSql.Provider.Sqlite     # SQLite
dotnet add package FreeSql.Provider.PostgreSQL # PostgreSQL

第二步:配置 Program.cs

把下面这段粘到你的 Program.cs 里,按需调整就行:

var builder = WebApplication.CreateBuilder(args);

var configuration = builder.Configuration;

builder.AddEasyAdminBlazor(new EasyAdminBlazorOptions
{
    EnableLoginCaptcha = true,
    EnableMessage = true,
    ShowHelp = true,
    AesKey = "XME2k7nA9vJy9osiU389469Y",
    AdminRouteSecret = "i4ByMAX4",
    Assemblies = [typeof(Program).Assembly],
    FreeSqlBuilder = a => a
        .UseConnectionString(DataType.MySql, configuration["ConnectionStrings:default"])
        .UseMonitorCommand(cmd => Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] {cmd.CommandText}\r\n")) // 调试时打印 SQL,上线可以注释掉
        .UseAutoSyncStructure(true) // 开发阶段自动同步表结构,上线建议关掉
})
    .AddEasyAdminBlazorMail() // 添加邮件扩展
    .AddEasyAdminBlazorTinyMCEEditor() // 编辑器扩展
    .AddEasyAdminBlazorRedis(configuration["Redis:ConnectionString"]!)
    .AddEasyAdminBlazorChat() // 聊天插件(依赖redis,没配置则不启用)
    .AddEasyAdminBlazorWeChat() // 微信插件
    .AddEasyAdminBlazorScheduler() // 计划任务扩展
    .AddEasyAdminBlazorFusionCache()
    .AddEasyAdminBlazorMultiTenant()
    .AddEasyAdminBlazorCaptcha(options =>
    {
        options.Chars = "0123456789";
    });  // 验证码

// Add services to the container.
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

// 注册 Session 服务
builder.Services.AddSession(options =>
{
    options.IdleTimeout = TimeSpan.FromMinutes(30);
    options.Cookie.HttpOnly = true;
    options.Cookie.IsEssential = true;
});

builder.Services.AddAntiforgery(o => o.HeaderName = "XSRF-TOKEN");

builder.Services.AddRazorComponents().AddInteractiveServerComponents();

builder.Services.AddBootstrapBlazorTableExportService();

builder.Services.Configure<HubOptions>(option => {
    option.MaximumReceiveMessageSize = null;
});

var app = builder.Build();

// 如果 EnableLocalization = true,请取消注释以下代码
//var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
//if (option != null)
//{
//    app.UseRequestLocalization(option.Value);
//}

app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });

app.UseStaticFiles();

app.UseAntiforgery();

app.MapRazorComponents<App>()
    .AddAdditionalAssemblies(typeof(EasyAdminBlazor._Imports).Assembly)
    .AddInteractiveServerRenderMode();

// 使用 Session
app.UseSession();

app.UseChat();
app.UseEasyAdminBlazor();

app.Run();

第三步:appsettings.json 完整配置示例

{
    "ConnectionStrings": {
        "Default": "Data Source=127.0.0.1;Port=3306;User ID=root;Password=123456; Initial Catalog=freesql_simple;Charset=utf8mb4; SslMode=none;Min pool size=1"
    },
    "Redis": {
        "ConnectionString": "127.0.0.1:6379,poolsize=10"
    },
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft.AspNetCore": "Warning"
        }
    },
    "AllowedHosts": "*",
    "FileSettings": {
        "DirectoryName": "uploads",
        "IncludeExtension": [".jpg", ".jpeg", ".png", ".gif", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt", ".webp"],
        "ExcludeExtension": [".exe", ".dll", ".jar", ".php", ".aspx", ".bat", ".cmd", ".vbs", ".js", ".html", ".htm"],
        "DateTimeDirectory": "yyyy/MM/dd",
        "KeepOriginalFile": false, //转换为webp后是否保留原文件
        "MaxImageWidth": 800,
        "WebpQuality": 80
    },
    "SmtpSettings": {
        "Server": "smtp.example.com",
        "Port": 587,
        "Username": "your_email@example.com",
        "Password": "your_email_password",
        "FromEmail": "your_email@example.com",
        "EnableSsl": true
    },
    "Wechat": {
        "App": {
            "AppKey": "your_app_key",
            "AppSecret": "your_app_secret"
        },
        "PayV3": {
            "AppId": "",
            "MchId": "",
            "ApiV3Key": "",
            "CertificatePath": "certs/apiclient_cert.pem",
            "KeyPath": "certs/apiclient_key.pem",
            "PubPath": "certs/pub_key.pem",
            "NotifyUrl": "",
            "BaseUrl": "https://api.mch.weixin.qq.com"
        }
    },
    "TinyMCE": {
        "ScriptSrc": "https://cdn.wang-zhan.cn/tinymce_8.3.2/tinymce.min.js"
    },
    "BootstrapBlazorOptions": {
        "ToastDelay": 4000,
        "MessageDelay": 4000,
        "SwalDelay": 4000,
        "EnableErrorLogger": true,
        "FallbackCulture": "en",
        "SupportedCultures": ["zh-CN", "en-US"],
        "TableSettings": {
            "CheckboxColumnWidth": 36
        },
        "WebClientOptions": {
            "EnableIpLocator": true
        },
        "IgnoreLocalizerMissing": true,
        "StepSettings": {
            "Short": "1",
            "Int": "1",
            "Long": "1",
            "Float": "0.1",
            "Double": "0.01",
            "Decimal": "0.01"
        },
        "DefaultCultureInfo": "zh-CN"
    }
}

第四步:在根目录的Components文件夹下添加 App.razor 页面

<!DOCTYPE html>
<html lang="en" data-bs-theme='light'>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="keywords" content="admin template,bootstrap,blazor,wasm,webassembly,UI,netcore,web,assembly">
    <meta name="description" content="基于Bootstrap和Freesql的后台系统,用于研发企业级中后台产品。">
    <meta name="author" content="gudufy (84383822@qq.com) www.wang-zhan.com.cn">
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon" href="favicon.png">
    <base href="/" />
    <link rel="stylesheet" href="@Assets["_content/BootstrapBlazor.FontAwesome/css/font-awesome.min.css"]" />
    <link rel="stylesheet" href="@Assets["_content/BootstrapBlazor/css/bootstrap.blazor.bundle.min.css"]" />
    <link rel="stylesheet" href="@Assets["_content/EasyAdminBlazor/ant.css"]">
    <link rel="stylesheet" href="@Assets["_content/EasyAdminBlazor/adminblazor.css"]" />
    <link rel="stylesheet" href="@Assets["EasyAdminBlazor.styles.css"]" />
    
    <link rel="stylesheet" href="@Assets["MyProjectName.styles.css"]" />
    <title>后台管理系统 - EasyAdminBlazor</title>
    <ImportMap></ImportMap>
    <HeadOutlet @rendermode="new InteractiveServerRenderMode(false)" />
</head>

<body>
    <Routes @rendermode="new InteractiveServerRenderMode(false)" />

    <ReconnectorOutlet ReconnectInterval="5000" @rendermode="new InteractiveServerRenderMode(false)" />

    <script Src="_content/BootstrapBlazor/js/bootstrap.blazor.bundle.min.js"></script>
    <script src="_framework/blazor.web.js"></script>
    <script src="@Assets["_content/EasyAdminBlazor/adminblazor.js"]"></script>
    <script Src="@Assets["_content/EasyAdminBlazor.HtmlEditor/TinyMCEEditor.razor.js"]"></script>
</body>

</html>

第五步:在根目录的Components文件夹下添加 Routes.razor 页面

<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new[] { typeof(MainLayout).Assembly }">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
    </Found>
</Router>

第六步:运行项目

dotnet run

后台登录地址:http://localhost:端口/admin/i4ByMAX4(i4ByMAX4 是上一步配置的 AdminRouteSecret 安全码,端口以启动日志为准)。默认管理员账号:admin,密码:123yyq。租户默认密码根据租户编码自动生成(如 vip123)。


下一步

项目跑起来之后,可以接着看:

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on EasyAdminBlazor:

Package Downloads
EasyAdminBlazor.HtmlEditor

EasyAdminBlazor的TinyMCE编辑器扩展

EasyAdminBlazor.Chat

EasyAdminBlazor的聊天扩展

EasyAdminBlazor.Captcha

EasyAdminBlazor的验证码扩展

EasyAdminBlazor.MultiTenant

EasyAdminBlazor的多租户扩展,提供数据库隔离的多租户支持。

EasyAdminBlazor.Scheduler

EasyAdminBlazor基于FreeScheduler的计划任务扩展

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.6.1 48 10/26/2026
2.5.1 53 10/23/2026
2.4.2 126 10/18/2026
2.4.1 114 10/15/2026
2.4.0 197 10/13/2026
2.3.2 167 10/2/2026
2.3.1 175 9/19/2026
2.3.0 210 9/17/2026
2.2.18 188 9/8/2026
2.2.17 174 8/30/2026
Loading failed