Skip to content

Commit fd991ac

Browse files
author
Feras Taleb
committed
Upgrading TestApiResource project from .NET Core 2.2 to .NET Core 3.1
1 parent 9abae31 commit fd991ac

3 files changed

Lines changed: 382 additions & 8 deletions

File tree

‎ApiResourceProjects/TestApiResource/Startup.cs‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ public Startup(IConfiguration configuration)
2525
// This method gets called by the runtime. Use this method to add services to the container.
2626
public void ConfigureServices(IServiceCollection services)
2727
{
28-
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
28+
29+
30+
//services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
31+
services.AddControllers();
2932

3033
services.AddAuthentication("Bearer")
3134
.AddJwtBearer("Bearer", options =>
@@ -50,11 +53,11 @@ public void ConfigureServices(IServiceCollection services)
5053
}
5154

5255
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
53-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
56+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5457
{
5558
app.UseCors("default");
5659

57-
if (env.IsDevelopment())
60+
if (env.EnvironmentName == "Development")
5861
{
5962
app.UseDeveloperExceptionPage();
6063
}
@@ -67,7 +70,20 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
6770
app.UseAuthentication();
6871

6972
app.UseHttpsRedirection();
70-
app.UseMvc();
73+
74+
75+
// Added after upgrading to .NET Core 3.1
76+
app.UseRouting();
77+
app.UseAuthorization();
78+
app.UseEndpoints(endpoints =>
79+
{
80+
endpoints.MapControllerRoute(
81+
name: "default",
82+
pattern: "{controller=Home}/{action=Index}/{id?}");
83+
});
84+
85+
// Removed after upgrading to .NET Core 3.1
86+
//app.UseMvc();
7187
}
7288
}
7389
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.App" />
10-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
11-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
9+
<!--<PackageReference Include="Microsoft.AspNetCore.App" />
10+
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />-->
11+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
12+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
1213
</ItemGroup>
1314

1415
</Project>

0 commit comments

Comments
 (0)