Skip to content

Commit cfca3f6

Browse files
committed
Updated from .NET Core 2.2 => .NET 5
1 parent 70e8252 commit cfca3f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+27574
-18358
lines changed

src/Northwind.Web/.bowerrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/Northwind.Web/Controllers/HomeController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace Northwind.Web.Controllers
88
{
99
public class HomeController : Controller
1010
{
11-
private readonly IHostingEnvironment hostingEnvironment;
11+
private readonly IWebHostEnvironment hostingEnvironment;
1212

13-
public HomeController(IHostingEnvironment env)
13+
public HomeController(IWebHostEnvironment env)
1414
{
1515
hostingEnvironment = env;
1616
}
Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
6-
<LangVersion>latest</LangVersion>
4+
<TargetFramework>net5.0</TargetFramework>
75
</PropertyGroup>
86

9-
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.App" />
11-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12-
<PackageReference Include="Northwind.Data" Version="1.1.0" />
13-
</ItemGroup>
14-
15-
<ItemGroup>
16-
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
17-
</ItemGroup>
18-
19-
<ItemGroup>
20-
<Folder Include="Database\" />
21-
</ItemGroup>
7+
<ItemGroup>
8+
<PackageReference Include="Northwind.Data" Version="1.1.0" />
9+
</ItemGroup>
2210
</Project>

src/Northwind.Web/Program.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore;
71
using Microsoft.AspNetCore.Hosting;
82
using Microsoft.Extensions.Configuration;
3+
using Microsoft.Extensions.Hosting;
94
using Microsoft.Extensions.Logging;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Threading.Tasks;
109

1110
namespace Northwind.Web
1211
{
1312
public class Program
1413
{
1514
public static void Main(string[] args)
1615
{
17-
BuildWebHost(args).Run();
16+
CreateHostBuilder(args).Build().Run();
1817
}
1918

20-
public static IWebHost BuildWebHost(string[] args) =>
21-
WebHost.CreateDefaultBuilder(args)
22-
.UseStartup<Startup>()
23-
.Build();
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
2425
}
2526
}

src/Northwind.Web/Startup.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.AspNetCore.Builder;
62
using Microsoft.AspNetCore.Hosting;
7-
using Microsoft.AspNetCore.Mvc;
3+
84
using Microsoft.Extensions.Configuration;
95
using Microsoft.Extensions.DependencyInjection;
6+
using Microsoft.Extensions.Hosting;
107

118
namespace Northwind.Web
129
{
@@ -22,11 +19,11 @@ public Startup(IConfiguration configuration)
2219
// This method gets called by the runtime. Use this method to add services to the container.
2320
public void ConfigureServices(IServiceCollection services)
2421
{
25-
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
22+
services.AddControllersWithViews();
2623
}
2724

2825
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
29-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
26+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3027
{
3128
if (env.IsDevelopment())
3229
{
@@ -35,15 +32,21 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
3532
else
3633
{
3734
app.UseExceptionHandler("/Home/Error");
35+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
36+
app.UseHsts();
3837
}
39-
38+
app.UseHttpsRedirection();
4039
app.UseStaticFiles();
4140

42-
app.UseMvc(routes =>
41+
app.UseRouting();
42+
43+
app.UseAuthorization();
44+
45+
app.UseEndpoints(endpoints =>
4346
{
44-
routes.MapRoute(
47+
endpoints.MapControllerRoute(
4548
name: "default",
46-
template: "{controller=Home}/{action=Index}/{id?}");
49+
pattern: "{controller=Home}/{action=Index}/{id?}");
4750
});
4851
}
4952
}

src/Northwind.Web/Views/Shared/Error.cshtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
1919
</p>
2020
<p>
21-
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
21+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
22+
It can result in displaying sensitive information from exceptions to end users.
23+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
24+
and restarting the app.
2225
</p>
Lines changed: 36 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,48 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Northwind Traders</title>
7-
8-
<environment include="Development">
9-
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
10-
<link rel="stylesheet" href="~/css/site.css" />
11-
</environment>
12-
<environment exclude="Development">
13-
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
14-
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
15-
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
16-
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
17-
</environment>
6+
<title>@ViewData["Title"] - Northwind.Web</title>
7+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
8+
<link rel="stylesheet" href="~/css/site.css" />
189
</head>
1910
<body>
20-
<nav class="navbar navbar-inverse navbar-fixed-top">
21-
<div class="container">
22-
<div class="navbar-header">
23-
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
24-
<span class="sr-only">Toggle navigation</span>
25-
<span class="icon-bar"></span>
26-
<span class="icon-bar"></span>
27-
<span class="icon-bar"></span>
11+
<header>
12+
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
13+
<div class="container">
14+
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Northwind.Web</a>
15+
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
16+
aria-expanded="false" aria-label="Toggle navigation">
17+
<span class="navbar-toggler-icon"></span>
2818
</button>
29-
<a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">Northwind.Web</a>
19+
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
20+
<ul class="navbar-nav flex-grow-1">
21+
<li class="nav-item">
22+
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
23+
</li>
24+
<li class="nav-item">
25+
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
26+
</li>
27+
</ul>
28+
</div>
3029
</div>
31-
<div class="navbar-collapse collapse">
32-
<ul class="nav navbar-nav">
33-
<li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li>
34-
</ul>
35-
</div>
36-
</div>
37-
</nav>
38-
<div class="container body-content">
39-
@RenderBody()
40-
<hr />
41-
<footer>
42-
<p>&copy; 2018 - Northwind Traders</p>
43-
</footer>
30+
</nav>
31+
</header>
32+
<div class="container">
33+
<main role="main" class="pb-3">
34+
@RenderBody()
35+
</main>
4436
</div>
4537

46-
<environment include="Development">
47-
<script src="~/lib/jquery/dist/jquery.js"></script>
48-
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
49-
<script src="~/js/site.js" asp-append-version="true"></script>
50-
</environment>
51-
<environment exclude="Development">
52-
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
53-
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
54-
asp-fallback-test="window.jQuery"
55-
crossorigin="anonymous"
56-
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
57-
</script>
58-
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
59-
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
60-
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
61-
crossorigin="anonymous"
62-
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
63-
</script>
64-
<script src="~/js/site.min.js" asp-append-version="true"></script>
65-
</environment>
66-
67-
@RenderSection("Scripts", required: false)
38+
<footer class="border-top footer text-muted">
39+
<div class="container">
40+
&copy; 2021 - Northwind.Web - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
41+
</div>
42+
</footer>
43+
<script src="~/lib/jquery/dist/jquery.min.js"></script>
44+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
45+
<script src="~/js/site.js" asp-append-version="true"></script>
46+
@await RenderSectionAsync("Scripts", required: false)
6847
</body>
6948
</html>
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,2 @@
1-
<environment include="Development">
2-
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
3-
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
4-
</environment>
5-
<environment exclude="Development">
6-
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"
7-
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
8-
asp-fallback-test="window.jQuery && window.jQuery.validator"
9-
crossorigin="anonymous"
10-
integrity="sha384-Fnqn3nxp3506LP/7Y3j/25BlWeA3PXTyT1l78LjECcPaKCV12TsZP7yyMxOe/G/k">
11-
</script>
12-
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js"
13-
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
14-
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
15-
crossorigin="anonymous"
16-
integrity="sha384-JrXK+k53HACyavUKOsL+NkmSesD2P+73eDMrbTtTk0h4RmOF8hF8apPlkp26JlyH">
17-
</script>
18-
</environment>
1+
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
2+
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@using Northwind.Web
1+
@using Northwind.Web
22
@using Northwind.Web.Models
33
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
{
1+
{
22
"Logging": {
3-
"IncludeScopes": false,
43
"LogLevel": {
5-
"Default": "Debug",
6-
"System": "Information",
7-
"Microsoft": "Information"
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
87
}
98
}
109
}

0 commit comments

Comments
 (0)