From 0991832b37c318be4cba7d9b9401332264c45f37 Mon Sep 17 00:00:00 2001 From: linezero Date: Sun, 13 Oct 2019 15:46:39 +0800 Subject: [PATCH 1/3] ASP.NET Core 3.0 --- src/ApplicationCore/ApplicationCore.csproj | 4 ++-- src/Infrastructure/Infrastructure.csproj | 4 ++-- src/NetCoreBBS/Controllers/UserController.cs | 4 ++-- src/NetCoreBBS/NetCoreBBS.csproj | 11 +++++------ src/NetCoreBBS/Startup.cs | 16 +++++++--------- tests/UnitTests/UnitTests.csproj | 15 +++++++++------ 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ApplicationCore/ApplicationCore.csproj b/src/ApplicationCore/ApplicationCore.csproj index 0b59a9e..60b9b1d 100644 --- a/src/ApplicationCore/ApplicationCore.csproj +++ b/src/ApplicationCore/ApplicationCore.csproj @@ -1,12 +1,12 @@  - netstandard2.0 + netstandard2.1 NetCoreBBS - + \ No newline at end of file diff --git a/src/Infrastructure/Infrastructure.csproj b/src/Infrastructure/Infrastructure.csproj index ec03054..c99f045 100644 --- a/src/Infrastructure/Infrastructure.csproj +++ b/src/Infrastructure/Infrastructure.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.1 NetCoreBBS.Infrastructure @@ -10,7 +10,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/NetCoreBBS/Controllers/UserController.cs b/src/NetCoreBBS/Controllers/UserController.cs index f5859b8..e0dcdc1 100644 --- a/src/NetCoreBBS/Controllers/UserController.cs +++ b/src/NetCoreBBS/Controllers/UserController.cs @@ -19,8 +19,8 @@ public class UserController : Controller private ITopicRepository _topic; private ITopicReplyRepository _reply; private UserManager UserManager; - private IHostingEnvironment _env; - public UserController(ITopicRepository topic, ITopicReplyRepository reply, UserManager userManager, IHostingEnvironment env) + private IWebHostEnvironment _env; + public UserController(ITopicRepository topic, ITopicReplyRepository reply, UserManager userManager, IWebHostEnvironment env) { _topic = topic; _reply = reply; diff --git a/src/NetCoreBBS/NetCoreBBS.csproj b/src/NetCoreBBS/NetCoreBBS.csproj index c9de8d6..2becbc0 100644 --- a/src/NetCoreBBS/NetCoreBBS.csproj +++ b/src/NetCoreBBS/NetCoreBBS.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp3.0 portable true NetCoreBBS @@ -16,11 +16,10 @@ - - - - - + + + + diff --git a/src/NetCoreBBS/Startup.cs b/src/NetCoreBBS/Startup.cs index 62a63df..c2b8803 100644 --- a/src/NetCoreBBS/Startup.cs +++ b/src/NetCoreBBS/Startup.cs @@ -24,16 +24,12 @@ namespace NetCoreBBS { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IConfiguration configuration) { - var builder = new ConfigurationBuilder() - .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddEnvironmentVariables(); - Configuration = builder.Build(); + Configuration = configuration; } - public IConfigurationRoot Configuration { get; } + public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) @@ -47,7 +43,9 @@ public void ConfigureServices(IServiceCollection services) }; }).AddEntityFrameworkStores().AddDefaultTokenProviders(); // Add framework services. - services.AddMvc(); + services.AddMvc(option=> { + option.EnableEndpointRouting = false; + }); services.AddScoped, Repository>(); services.AddScoped(); services.AddScoped(); @@ -71,7 +69,7 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { app.UseRequestIPMiddleware(); diff --git a/tests/UnitTests/UnitTests.csproj b/tests/UnitTests/UnitTests.csproj index 3632e3f..f801781 100644 --- a/tests/UnitTests/UnitTests.csproj +++ b/tests/UnitTests/UnitTests.csproj @@ -1,13 +1,16 @@ - + - - netcoreapp2.0 + + netcoreapp3.0 + + false - - - + + + + From d0569f801c0878c10195529a4e855a42893b2d53 Mon Sep 17 00:00:00 2001 From: linezero Date: Sun, 13 Oct 2019 15:48:39 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95a07e4..7c1075d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ASP.NET Core + EF Core Sqlite + Bootstrap ## 开发 1. `git clone https://github.com/linezero/NETCoreBBS.git` -2. 使用 Visual Studio 2017 打开 `NetCoreBBS.sln` +2. 使用 Visual Studio 2019 打开 `NetCoreBBS.sln` 3. 点击 `调试->开始调试` 即可运行起来,或者直接点击工具栏上的`NetCoreBBS`即可。 注意:默认为80端口,可能会和本地端口冲突,可以到Program.cs 中更改 `.UseUrls("http://*:80")`,然后更改启动URL既可。 From 71ac2c572f8d25d79bad0fdfd695d7d6d7e2bcf6 Mon Sep 17 00:00:00 2001 From: linezero Date: Fri, 1 May 2020 11:41:08 +0800 Subject: [PATCH 3/3] ASP.NET Core 3.1 --- src/ApplicationCore/ApplicationCore.csproj | 2 +- src/Infrastructure/Infrastructure.csproj | 2 +- src/NetCoreBBS/NetCoreBBS.csproj | 22 ++++--------------- src/NetCoreBBS/Startup.cs | 20 ++++++++--------- src/NetCoreBBS/Views/Home/About.cshtml | 5 ++--- src/NetCoreBBS/Views/Home/Index.cshtml | 3 +-- src/NetCoreBBS/Views/Shared/_Layout.cshtml | 2 +- .../Views/Shared/_SidebarPartial.cshtml | 4 ++-- src/NetCoreBBS/bundleconfig.json | 16 -------------- src/NetCoreBBS/web.config | 14 ------------ 10 files changed, 21 insertions(+), 69 deletions(-) delete mode 100644 src/NetCoreBBS/web.config diff --git a/src/ApplicationCore/ApplicationCore.csproj b/src/ApplicationCore/ApplicationCore.csproj index 60b9b1d..0dc4a40 100644 --- a/src/ApplicationCore/ApplicationCore.csproj +++ b/src/ApplicationCore/ApplicationCore.csproj @@ -6,7 +6,7 @@ - + \ No newline at end of file diff --git a/src/Infrastructure/Infrastructure.csproj b/src/Infrastructure/Infrastructure.csproj index c99f045..7fa0fa0 100644 --- a/src/Infrastructure/Infrastructure.csproj +++ b/src/Infrastructure/Infrastructure.csproj @@ -10,7 +10,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/src/NetCoreBBS/NetCoreBBS.csproj b/src/NetCoreBBS/NetCoreBBS.csproj index 2becbc0..ea1254f 100644 --- a/src/NetCoreBBS/NetCoreBBS.csproj +++ b/src/NetCoreBBS/NetCoreBBS.csproj @@ -1,11 +1,8 @@  - netcoreapp3.0 - portable - true + netcoreapp3.1 NetCoreBBS - Exe NetCoreBBS @@ -16,22 +13,11 @@ - - + + - - - - - - - - - - - - + diff --git a/src/NetCoreBBS/Startup.cs b/src/NetCoreBBS/Startup.cs index c2b8803..f478b66 100644 --- a/src/NetCoreBBS/Startup.cs +++ b/src/NetCoreBBS/Startup.cs @@ -43,9 +43,7 @@ public void ConfigureServices(IServiceCollection services) }; }).AddEntityFrameworkStores().AddDefaultTokenProviders(); // Add framework services. - services.AddMvc(option=> { - option.EnableEndpointRouting = false; - }); + services.AddMvc(); services.AddScoped, Repository>(); services.AddScoped(); services.AddScoped(); @@ -76,19 +74,19 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF InitializeNetCoreBBSDatabase(app.ApplicationServices); app.UseDeveloperExceptionPage(); + app.UseStatusCodePages(); app.UseStaticFiles(); + app.UseRouting(); app.UseAuthentication(); - app.UseStatusCodePages(); + app.UseAuthorization(); - app.UseMvc(routes => + app.UseEndpoints(endpoint => { - routes.MapRoute( - name: "areaRoute", - template: "{area:exists}/{controller}/{action}", + endpoint.MapControllerRoute(name: "areaRoute", + pattern: "{area:exists}/{controller}/{action}", defaults: new { action = "Index" }); - routes.MapRoute( - name: "default", - template: "{controller=Home}/{action=Index}/{id?}"); + endpoint.MapControllerRoute(name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); }); } diff --git a/src/NetCoreBBS/Views/Home/About.cshtml b/src/NetCoreBBS/Views/Home/About.cshtml index 5add21e..51c06a6 100644 --- a/src/NetCoreBBS/Views/Home/About.cshtml +++ b/src/NetCoreBBS/Views/Home/About.cshtml @@ -6,13 +6,12 @@

.NET Core 开发
- VS Code 或者 VS 2017
- 更多详细:dot.net
+ VS Code 或者 VS 2019

论坛系统介绍:

系统开发:
ASP.NET Core + EF Core Sqlite + Bootstrap
运行环境:
- Ubuntu 14.04 + Kestrel

+ Ubuntu 16.04 + Kestrel+Nginx

博客介绍: LineZero's Blog diff --git a/src/NetCoreBBS/Views/Home/Index.cshtml b/src/NetCoreBBS/Views/Home/Index.cshtml index 478a1f4..56d29f9 100644 --- a/src/NetCoreBBS/Views/Home/Index.cshtml +++ b/src/NetCoreBBS/Views/Home/Index.cshtml @@ -60,7 +60,6 @@
@@ -73,7 +72,7 @@
- +
diff --git a/src/NetCoreBBS/Views/Shared/_SidebarPartial.cshtml b/src/NetCoreBBS/Views/Shared/_SidebarPartial.cshtml index 705793c..575ebb0 100644 --- a/src/NetCoreBBS/Views/Shared/_SidebarPartial.cshtml +++ b/src/NetCoreBBS/Views/Shared/_SidebarPartial.cshtml @@ -5,13 +5,13 @@