ASP.NET Core 轻量化开源论坛项目,ASP.NET Core Light forum NETCoreBBS
采用 ASP.NET Core + EF Core Sqlite + Bootstrap 开发。
GitHub: https://github.com/linezero/NETCoreBBS
开发
git clone https://github.com/linezero/NETCoreBBS.git
使用 Visual Studio 2017 打开
NetCoreBBS.sln
点击
调试->开始调试
即可运行起来,或者直接点击工具栏上的NetCoreBBS
即可。
注意:默认为80端口,可能会和本地端口冲突,可以到Program.cs 中更改 .UseUrls("http://*:80")
,然后更改启动URL既可。
功能
节点功能
主题发布
主题回复
主题筛选
用户登录注册
主题置顶
后台管理
个人中心
技术点大合集
架构 Clean Architecture
1. Areas
重点代码:
app.UseMvc(routes => { routes.MapRoute( name: "areaRoute", template: "{area:exists}/{controller}/{action}", defaults: new { action = "Index" }); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); });
增加一个 areaRoute ,然后添加对应的Areas 文件夹,然后Areas里的控制器里加上 [Area("Admin")] 。
2. ViewComponents
在项目里的ViewComponents 文件夹,注意对应视图在 Views\Shared\Components 文件夹里。
3. Middleware
RequestIPMiddleware 记录ip及相关信息的中间件
public class RequestIPMiddleware {
private readonly RequestDelegate _next;
private readonly ILogger _logger;
public RequestIPMiddleware(RequestDelegate next) { _next = next; _logger = LogManager.GetCurrentClassLogger(); }
public async Task Invoke(HttpContext httpContext) {
var url = httpContext.Request.Path.ToString();
if (!(url.Contains(