EasyAdminBlazor 2.2.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyAdminBlazor --version 2.2.6
                    
NuGet\Install-Package EasyAdminBlazor -Version 2.2.6
                    
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.2.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyAdminBlazor" Version="2.2.6" />
                    
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.2.6
                    
#r "nuget: EasyAdminBlazor, 2.2.6"
                    
#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.2.6
                    
#: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.2.6
                    
Install as a Cake Addin
#tool nuget:?package=EasyAdminBlazor&version=2.2.6
                    
Install as a Cake Tool

🚀 快速开始

环境要求

  • .NET 10 SDK
  • MySQL 8.0+(或其他 FreeSql 支持的数据库)
  • (可选)Redis

全新项目

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

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

# 进入项目运行
cd MyProjectName
dotnet run

现有项目

第一步:安装 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

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 => System.Console.WriteLine($"[{DateTime.Now.ToString("HH:mm:ss")}] {cmd.CommandText}\r\n"))//监听SQL语句
        .UseAutoSyncStructure(true)
})
    .AddEasyAdminBlazorMail() // 添加smtp邮件扩展
    .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["EasyAdminBlazor.Test.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

默认管理员账号: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 (12)

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.4.0 78 10/13/2026
2.4.0-preview.6 101 10/10/2026
2.4.0-preview.5 84 10/8/2026
2.4.0-preview.4 90 10/3/2026
2.4.0-preview.3 100 10/3/2026
2.4.0-preview.2 80 10/3/2026
2.4.0-preview.1 78 10/3/2026
2.4.0-preview 144 10/3/2026
2.3.2 158 10/2/2026
2.3.1 171 9/19/2026
2.3.0 204 9/17/2026
2.2.18 183 9/8/2026
2.2.17 169 8/30/2026
2.2.16 111 8/26/2026
2.2.15 193 8/16/2026
2.2.14 161 8/14/2026
2.2.13 150 6/23/2026
2.2.12 145 6/19/2026
2.2.11 162 6/13/2026
2.2.6 148 5/29/2026
Loading failed