Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit db33493

Browse files
committed
Initial migration to 3.0
1 parent 5e84452 commit db33493

11 files changed

+69
-71
lines changed

src/BackEnd/BackEnd.csproj

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<UserSecretsId>aspnet-BackEnd-931E56BD-86CB-4A96-BD99-2C6A6ABB0829</UserSecretsId>
6-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
76
</PropertyGroup>
87

98
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.App" />
11-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Api.Analyzers" Version="2.2.0" />
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
13-
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="2.2.0" />
14-
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
9+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview5*" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview5*" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0-preview5*" />
12+
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.0.0-preview5*" />
13+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview5*" />
14+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/BackEnd/Program.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
using Microsoft.AspNetCore;
2-
using Microsoft.AspNetCore.Hosting;
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
33

44
namespace BackEnd
55
{
66
public class Program
77
{
88
public static void Main(string[] args)
99
{
10-
CreateWebHostBuilder(args).Build().Run();
10+
CreateHostBuilder(args).Build().Run();
1111
}
1212

13-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
14-
WebHost.CreateDefaultBuilder(args)
15-
.UseStartup<Startup>();
16-
13+
public static IHostBuilder CreateHostBuilder(string[] args) =>
14+
Host.CreateDefaultBuilder(args)
15+
.ConfigureWebHostDefaults(webHostBuilder =>
16+
{
17+
webHostBuilder.UseStartup<Startup>();
18+
});
1719
}
1820
}

src/BackEnd/Startup.cs

+14-12
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
using Microsoft.EntityFrameworkCore;
1010
using Microsoft.Extensions.Configuration;
1111
using Microsoft.Extensions.DependencyInjection;
12-
using Swashbuckle.AspNetCore.Swagger;
12+
using Microsoft.Extensions.Hosting;
1313
using BackEnd.Data;
14+
using Microsoft.OpenApi.Models;
1415

1516
[assembly: ApiConventionType(typeof(DefaultApiConventions))]
1617

@@ -39,43 +40,44 @@ public void ConfigureServices(IServiceCollection services)
3940
}
4041
});
4142

42-
services.AddMvc()
43-
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
43+
services.AddControllers()
44+
.AddNewtonsoftJson()
45+
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
4446

4547
services.AddHealthChecks()
4648
.AddDbContextCheck<ApplicationDbContext>();
4749

4850
services.AddSwaggerGen(options =>
4951
{
50-
options.SwaggerDoc("v1", new Info { Title = "Conference Planner API", Version = "v1" });
52+
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Conference Planner API", Version = "v1" });
5153
});
5254
}
5355

54-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
56+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5557
{
5658
if (env.IsDevelopment())
5759
{
5860
app.UseDeveloperExceptionPage();
5961
app.UseDatabaseErrorPage();
6062
}
61-
else
62-
{
63-
app.UseHsts();
64-
}
6563

6664
app.UseHttpsRedirection();
6765

68-
app.UseHealthChecks("/health");
69-
7066
app.UseSwagger();
7167

7268
app.UseSwaggerUI(options =>
7369
{
7470
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Conference Planner API v1");
7571
});
7672

77-
app.UseMvc();
73+
app.UseRouting();
7874

75+
app.UseEndpoints(endpoints =>
76+
{
77+
endpoints.MapControllers();
78+
endpoints.MapHealthChecks("/health");
79+
});
80+
7981
app.Run(context =>
8082
{
8183
context.Response.Redirect("/swagger");

src/ConferenceDTO/SessionResponse.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ public class SessionResponse : Session
88
{
99
public Track Track { get; set; }
1010

11-
public ICollection<Speaker> Speakers { get; set; } = new List<Speaker>();
11+
public List<Speaker> Speakers { get; set; } = new List<Speaker>();
1212

13-
public ICollection<Tag> Tags { get; set; } = new List<Tag>();
13+
public List<Tag> Tags { get; set; } = new List<Tag>();
1414
}
1515
}

src/FrontEnd/Areas/Identity/IdentityHostingStartup.cs

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public void Configure(IWebHostBuilder builder)
3838
options.Password.RequireUppercase = false;
3939
options.Password.RequireNonAlphanumeric = false;
4040
})
41-
.AddDefaultUI(UIFramework.Bootstrap4)
4241
.AddEntityFrameworkStores<IdentityDbContext>()
4342
.AddClaimsPrincipalFactory<ClaimsPrincipalFactory>();
4443
});

src/FrontEnd/FrontEnd.csproj

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<UserSecretsId>aspnet-FrontEnd-18BDC1FA-5BA8-408A-BC82-D8DB0496B86B</UserSecretsId>
6-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
76
</PropertyGroup>
87

98
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.App" />
11-
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="2.2.0" />
12-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
9+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview5*" />
10+
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview5*" />
11+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview5*" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0-preview5*" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview5*" />
14+
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.0.0-preview5*" />
15+
<PackageReference Include="Microsoft.AspNet.WebApi.Client " Version="5.2.7" />
16+
<!--<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />-->
1417
</ItemGroup>
1518

1619
<ItemGroup>

src/FrontEnd/Program.cs

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using FrontEnd.Infrastructure;
7-
using Microsoft.AspNetCore;
8-
using Microsoft.AspNetCore.Hosting;
9-
using Microsoft.Extensions.Configuration;
10-
using Microsoft.Extensions.Logging;
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
113

124
namespace FrontEnd
135
{
146
public class Program
157
{
168
public static void Main(string[] args)
179
{
18-
CreateWebHostBuilder(args).Build().Run();
10+
CreateHostBuilder(args).Build().Run();
1911
}
2012

21-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
22-
WebHost.CreateDefaultBuilder(args)
23-
.UseStartup<Startup>();
13+
public static IHostBuilder CreateHostBuilder(string[] args) =>
14+
Host.CreateDefaultBuilder(args)
15+
.ConfigureWebHostDefaults(webHostBuilder =>
16+
{
17+
webHostBuilder.UseStartup<Startup>();
18+
});
2419
}
2520
}

src/FrontEnd/Properties/launchSettings.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
"commandName": "IISExpress",
1313
"launchBrowser": true,
1414
"environmentVariables": {
15-
"ASPNETCORE_ENVIRONMENT": "Development",
16-
"AASPNETCORE_HTTPS_PORT": "44374"
15+
"ASPNETCORE_ENVIRONMENT": "Development"
1716
}
1817
},
1918
"FrontEnd": {
2019
"commandName": "Project",
2120
"launchBrowser": true,
22-
"launchUrl": "",
2321
"applicationUrl": "https://localhost:44374;http://localhost:55994",
2422
"environmentVariables": {
2523
"ASPNETCORE_ENVIRONMENT": "Development"

src/FrontEnd/Startup.cs

+14-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
using System;
2-
using System.Security.Claims;
32
using FrontEnd.Data;
43
using FrontEnd.HealthChecks;
54
using FrontEnd.Services;
65
using Microsoft.AspNetCore.Builder;
76
using Microsoft.AspNetCore.Hosting;
87
using Microsoft.AspNetCore.Mvc;
9-
using Microsoft.AspNetCore.Routing;
108
using Microsoft.Extensions.Configuration;
119
using Microsoft.Extensions.DependencyInjection;
10+
using Microsoft.Extensions.Hosting;
1211

1312
namespace FrontEnd
1413
{
@@ -39,15 +38,15 @@ public void ConfigureServices(IServiceCollection services)
3938
client.BaseAddress = new Uri(Configuration["serviceUrl"]);
4039
});
4140

42-
services.AddMvc(options =>
41+
services.AddRazorPages(options =>
4342
{
44-
options.Filters.AddService<RequireLoginFilter>();
43+
options.Conventions.AuthorizeFolder("/Admin", "Admin");
4544
})
46-
.AddRazorPagesOptions(options =>
45+
.AddMvcOptions(options =>
4746
{
48-
options.Conventions.AuthorizeFolder("/Admin", "Admin");
47+
options.Filters.AddService<RequireLoginFilter>();
4948
})
50-
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
49+
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
5150

5251
services.AddHealthChecks()
5352
.AddCheck<BackendHealthCheck>("backend")
@@ -56,7 +55,7 @@ public void ConfigureServices(IServiceCollection services)
5655
services.AddSingleton<IAdminService, AdminService>();
5756
}
5857

59-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
58+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
6059
{
6160
if (env.IsDevelopment())
6261
{
@@ -69,21 +68,20 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
6968
app.UseHsts();
7069
}
7170

72-
app.UseStatusCodePagesWithReExecute("/Status/{0}");
71+
//app.UseStatusCodePagesWithReExecute("/Status/{0}");
7372

7473
app.UseHttpsRedirection();
75-
7674
app.UseStaticFiles();
7775

78-
app.UseAuthentication();
76+
app.UseRouting();
7977

80-
app.UseHealthChecks("/health");
78+
app.UseAuthentication();
79+
app.UseAuthorization();
8180

82-
app.UseMvc(routes =>
81+
app.UseEndpoints(endpoints =>
8382
{
84-
routes.MapRoute(
85-
name: "default",
86-
template: "{controller=Home}/{action=Index}/{id?}");
83+
endpoints.MapRazorPages();
84+
endpoints.MapHealthChecks("/health");
8785
});
8886
}
8987
}

src/FrontEnd/appsettings.Development.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"LogLevel": {
55
"Default": "Debug",
66
"System": "Information",
7-
"Microsoft": "Information"
7+
"Microsoft": "Debug"
88
}
99
}
1010
}

src/FrontEnd/appsettings.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"ServiceUrl": "http://localhost:56009/",
3-
"Admin": "<username>",
43
"Logging": {
54
"IncludeScopes": false,
65
"LogLevel": {
7-
"Default": "Warning"
6+
"Default": "Information",
7+
"Microsoft": "Warning",
8+
"Microsoft.Hosting.Lifetime": "Information"
89
}
910
},
1011
"ConnectionStrings": {

0 commit comments

Comments
 (0)