From 2ff91f37402a2efe8289878895235a06b19a0aaa Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Thu, 28 Jun 2018 22:06:29 -0500 Subject: [PATCH] Update app to ASP.NET Core 2.1 --- README.md | 3 ++- TagHelpersDemo.Tests/TagHelpersDemo.Tests.csproj | 7 ++++--- TagHelpersDemo.sln | 3 +-- TagHelpersDemo/Program.cs | 9 ++++----- TagHelpersDemo/Startup.cs | 15 +++++---------- TagHelpersDemo/TagHelpersDemo.csproj | 9 +++------ TagHelpersDemo/appsettings.Development.json | 3 +-- TagHelpersDemo/appsettings.json | 6 +++--- global.json | 5 ----- 9 files changed, 23 insertions(+), 37 deletions(-) delete mode 100644 global.json diff --git a/README.md b/README.md index c2a491f..3c49b3c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # TagHelpersDemo -An ASP.NET Core MVC application demonstrating the use of tag helpers + +An ASP.NET Core MVC app demonstrating the use of [Tag Helpers](https://docs.microsoft.com/aspnet/core/mvc/views/tag-helpers/intro) diff --git a/TagHelpersDemo.Tests/TagHelpersDemo.Tests.csproj b/TagHelpersDemo.Tests/TagHelpersDemo.Tests.csproj index 8bd2615..436d779 100644 --- a/TagHelpersDemo.Tests/TagHelpersDemo.Tests.csproj +++ b/TagHelpersDemo.Tests/TagHelpersDemo.Tests.csproj @@ -1,11 +1,12 @@ - + - netcoreapp2.0 + netcoreapp2.1 false - + + diff --git a/TagHelpersDemo.sln b/TagHelpersDemo.sln index 05a85d5..9eec438 100644 --- a/TagHelpersDemo.sln +++ b/TagHelpersDemo.sln @@ -9,11 +9,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore - global.json = global.json NuGet.Config = NuGet.Config EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagHelpersDemo.Tests", "TagHelpersDemo.Tests\TagHelpersDemo.Tests.csproj", "{823B7081-4304-4D16-A2D8-28B30F1CEB7A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TagHelpersDemo.Tests", "TagHelpersDemo.Tests\TagHelpersDemo.Tests.csproj", "{823B7081-4304-4D16-A2D8-28B30F1CEB7A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/TagHelpersDemo/Program.cs b/TagHelpersDemo/Program.cs index 8a9b4ac..c4c5ce1 100644 --- a/TagHelpersDemo/Program.cs +++ b/TagHelpersDemo/Program.cs @@ -5,12 +5,11 @@ namespace TagHelpersDemo { public class Program { - public static void Main(string[] args) => - BuildWebHost(args).Run(); + public static void Main(string[] args) => + CreateWebHostBuilder(args).Build().Run(); - public static IWebHost BuildWebHost(string[] args) => + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) - .UseStartup() - .Build(); + .UseStartup(); } } \ No newline at end of file diff --git a/TagHelpersDemo/Startup.cs b/TagHelpersDemo/Startup.cs index 0405f09..8eeee32 100644 --- a/TagHelpersDemo/Startup.cs +++ b/TagHelpersDemo/Startup.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using TagHelpersDemo.Services; namespace TagHelpersDemo @@ -14,31 +14,26 @@ public class Startup 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) { services.AddTransient(); - // Add framework services. - services.AddMvc(); + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } - // 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, IHostingEnvironment env) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); - if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); - app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); } diff --git a/TagHelpersDemo/TagHelpersDemo.csproj b/TagHelpersDemo/TagHelpersDemo.csproj index 3d61061..6c36468 100644 --- a/TagHelpersDemo/TagHelpersDemo.csproj +++ b/TagHelpersDemo/TagHelpersDemo.csproj @@ -1,15 +1,12 @@  - netcoreapp2.0 - .NET Core 2.0 + netcoreapp2.1 + .NET Core 2.1 - - - - + \ No newline at end of file diff --git a/TagHelpersDemo/appsettings.Development.json b/TagHelpersDemo/appsettings.Development.json index fa8ce71..edcffc5 100644 --- a/TagHelpersDemo/appsettings.Development.json +++ b/TagHelpersDemo/appsettings.Development.json @@ -1,10 +1,9 @@ { "Logging": { - "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } } -} +} \ No newline at end of file diff --git a/TagHelpersDemo/appsettings.json b/TagHelpersDemo/appsettings.json index 5fff67b..d713e81 100644 --- a/TagHelpersDemo/appsettings.json +++ b/TagHelpersDemo/appsettings.json @@ -1,8 +1,8 @@ { "Logging": { - "IncludeScopes": false, "LogLevel": { "Default": "Warning" } - } -} + }, + "AllowedHosts": "*" +} \ No newline at end of file diff --git a/global.json b/global.json deleted file mode 100644 index 00b3f36..0000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "2.1.4" - } -} \ No newline at end of file