From 42b88c15f2bbbf6531f7170a149bf2dab3d24e9d Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Fri, 19 May 2017 11:36:17 +0100 Subject: [PATCH] Make all templates as consistent as possible with stock MVC Core 2.0 one --- templates/AngularSpa/AngularSpa.csproj | 27 +++++++++-------- .../AngularSpa/Controllers/HomeController.cs | 2 ++ templates/AngularSpa/Program.cs | 15 +++++----- templates/AngularSpa/Startup.cs | 21 ++++---------- .../AngularSpa/Views/Shared/Error.cshtml | 15 ++++++++++ .../AngularSpa/Views/Shared/_Layout.cshtml | 23 ++++++++------- .../AngularSpa/Views/_ViewImports.cshtml | 4 +-- .../AngularSpa/appsettings.Development.json | 19 ++++++++++++ templates/AngularSpa/appsettings.json | 13 ++++++--- templates/AngularSpa/web.config | 14 --------- templates/AureliaSpa/AureliaSpa.csproj | 17 ++++++----- .../app/components/navmenu/navmenu.html | 2 +- .../AureliaSpa/Controllers/HomeController.cs | 2 ++ templates/AureliaSpa/Program.cs | 15 +++++----- templates/AureliaSpa/Startup.cs | 22 ++++---------- .../AureliaSpa/Views/Shared/Error.cshtml | 15 ++++++++++ .../AureliaSpa/Views/Shared/_Layout.cshtml | 21 +++++++------- .../AureliaSpa/Views/_ViewImports.cshtml | 4 +-- .../AureliaSpa/appsettings.Development.json | 19 ++++++++++++ templates/AureliaSpa/appsettings.json | 13 ++++++--- .../KnockoutSpa/Controllers/HomeController.cs | 2 ++ templates/KnockoutSpa/KnockoutSpa.csproj | 17 ++++++----- templates/KnockoutSpa/Program.cs | 15 +++++----- templates/KnockoutSpa/Startup.cs | 18 +++--------- .../KnockoutSpa/Views/Shared/Error.cshtml | 15 ++++++++++ .../KnockoutSpa/Views/Shared/_Layout.cshtml | 29 ++++++++++--------- .../KnockoutSpa/Views/_ViewImports.cshtml | 4 +-- .../KnockoutSpa/appsettings.Development.json | 19 ++++++++++++ templates/KnockoutSpa/appsettings.json | 13 ++++++--- templates/KnockoutSpa/web.config | 14 --------- .../Controllers/HomeController.cs | 2 ++ templates/ReactReduxSpa/Program.cs | 15 +++++----- templates/ReactReduxSpa/ReactReduxSpa.csproj | 27 +++++++++-------- templates/ReactReduxSpa/Startup.cs | 21 ++++---------- .../ReactReduxSpa/Views/Shared/Error.cshtml | 15 ++++++++++ .../ReactReduxSpa/Views/Shared/_Layout.cshtml | 25 ++++++++-------- .../ReactReduxSpa/Views/_ViewImports.cshtml | 4 +-- .../appsettings.Development.json | 19 ++++++++++++ templates/ReactReduxSpa/appsettings.json | 13 ++++++--- templates/ReactReduxSpa/web.config | 14 --------- .../ReactSpa/Controllers/HomeController.cs | 2 ++ templates/ReactSpa/Program.cs | 15 +++++----- templates/ReactSpa/ReactSpa.csproj | 17 ++++++----- templates/ReactSpa/Startup.cs | 21 ++++---------- templates/ReactSpa/Views/Shared/Error.cshtml | 15 ++++++++++ .../ReactSpa/Views/Shared/_Layout.cshtml | 29 ++++++++++--------- templates/ReactSpa/Views/_ViewImports.cshtml | 4 +-- .../ReactSpa/appsettings.Development.json | 19 ++++++++++++ templates/ReactSpa/appsettings.json | 13 ++++++--- templates/ReactSpa/web.config | 14 --------- templates/VueSpa/ClientApp/boot.ts | 1 + .../ClientApp/components/navmenu/navmenu.css | 7 ----- templates/VueSpa/ClientApp/css/site.css | 6 ++++ .../VueSpa/Controllers/HomeController.cs | 2 ++ templates/VueSpa/Program.cs | 15 +++++----- templates/VueSpa/Startup.cs | 21 ++++---------- templates/VueSpa/Views/Shared/Error.cshtml | 15 ++++++++++ templates/VueSpa/Views/Shared/_Layout.cshtml | 26 ++++++++++------- templates/VueSpa/Views/_ViewImports.cshtml | 4 +-- templates/VueSpa/VueSpa.csproj | 17 ++++++----- templates/VueSpa/appsettings.Development.json | 19 ++++++++++++ templates/VueSpa/appsettings.json | 13 ++++++--- templates/VueSpa/web.config | 14 --------- templates/VueSpa/webpack.config.js | 3 +- 64 files changed, 521 insertions(+), 375 deletions(-) create mode 100644 templates/AngularSpa/appsettings.Development.json delete mode 100644 templates/AngularSpa/web.config create mode 100644 templates/AureliaSpa/appsettings.Development.json create mode 100644 templates/KnockoutSpa/appsettings.Development.json delete mode 100644 templates/KnockoutSpa/web.config create mode 100644 templates/ReactReduxSpa/appsettings.Development.json delete mode 100644 templates/ReactReduxSpa/web.config create mode 100644 templates/ReactSpa/appsettings.Development.json delete mode 100644 templates/ReactSpa/web.config create mode 100644 templates/VueSpa/ClientApp/css/site.css create mode 100644 templates/VueSpa/appsettings.Development.json delete mode 100644 templates/VueSpa/web.config diff --git a/templates/AngularSpa/AngularSpa.csproj b/templates/AngularSpa/AngularSpa.csproj index b0cea30..7e49bba 100644 --- a/templates/AngularSpa/AngularSpa.csproj +++ b/templates/AngularSpa/AngularSpa.csproj @@ -1,23 +1,25 @@ - + + netcoreapp2.0 true - false + $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; - - - - - - - - - - + + + + + + + + + + + @@ -33,4 +35,5 @@ + \ No newline at end of file diff --git a/templates/AngularSpa/Controllers/HomeController.cs b/templates/AngularSpa/Controllers/HomeController.cs index 9d75da8..2889abd 100644 --- a/templates/AngularSpa/Controllers/HomeController.cs +++ b/templates/AngularSpa/Controllers/HomeController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; @@ -15,6 +16,7 @@ namespace WebApplicationBasic.Controllers public IActionResult Error() { + ViewData["RequestId"] = Activity.Current?.Id ?? HttpContext.TraceIdentifier; return View(); } } diff --git a/templates/AngularSpa/Program.cs b/templates/AngularSpa/Program.cs index 193f1e2..e1e634e 100644 --- a/templates/AngularSpa/Program.cs +++ b/templates/AngularSpa/Program.cs @@ -3,7 +3,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace WebApplicationBasic { @@ -11,14 +14,12 @@ namespace WebApplicationBasic { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); - - host.Run(); - } } } diff --git a/templates/AngularSpa/Startup.cs b/templates/AngularSpa/Startup.cs index e5d73ed..d381113 100644 --- a/templates/AngularSpa/Startup.cs +++ b/templates/AngularSpa/Startup.cs @@ -7,41 +7,32 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace WebApplicationBasic { 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) - .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: 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) { - // Add framework services. services.AddMvc(); } // 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.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { + app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions + { HotModuleReplacement = true }); } diff --git a/templates/AngularSpa/Views/Shared/Error.cshtml b/templates/AngularSpa/Views/Shared/Error.cshtml index 473b35d..78e35d5 100644 --- a/templates/AngularSpa/Views/Shared/Error.cshtml +++ b/templates/AngularSpa/Views/Shared/Error.cshtml @@ -4,3 +4,18 @@

Error.

An error occurred while processing your request.

+ +@if (!string.IsNullOrEmpty((string)ViewData["RequestId"])) +{ +

+ Request ID: @ViewData["RequestId"] +

+} + +

Development Mode

+

+ Swapping to Development environment will display more detailed information about the error that occurred. +

+

+ Development environment should not be enabled in deployed applications, 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 ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. +

diff --git a/templates/AngularSpa/Views/Shared/_Layout.cshtml b/templates/AngularSpa/Views/Shared/_Layout.cshtml index 799964f..d5b7a0f 100644 --- a/templates/AngularSpa/Views/Shared/_Layout.cshtml +++ b/templates/AngularSpa/Views/Shared/_Layout.cshtml @@ -1,15 +1,16 @@ - - - - @ViewData["Title"] - WebApplicationBasic - - - - - @RenderBody() + + + + @ViewData["Title"] - WebApplicationBasic + - @RenderSection("scripts", required: false) - + + + + @RenderBody() + + @RenderSection("scripts", required: false) + diff --git a/templates/AngularSpa/Views/_ViewImports.cshtml b/templates/AngularSpa/Views/_ViewImports.cshtml index e7b4f83..8edbc68 100644 --- a/templates/AngularSpa/Views/_ViewImports.cshtml +++ b/templates/AngularSpa/Views/_ViewImports.cshtml @@ -1,3 +1,3 @@ @using WebApplicationBasic -@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" -@addTagHelper "*, Microsoft.AspNetCore.SpaServices" +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Microsoft.AspNetCore.SpaServices diff --git a/templates/AngularSpa/appsettings.Development.json b/templates/AngularSpa/appsettings.Development.json new file mode 100644 index 0000000..457e003 --- /dev/null +++ b/templates/AngularSpa/appsettings.Development.json @@ -0,0 +1,19 @@ +{ + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + }, + "Console": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } + } +} diff --git a/templates/AngularSpa/appsettings.json b/templates/AngularSpa/appsettings.json index 723c096..c851e12 100644 --- a/templates/AngularSpa/appsettings.json +++ b/templates/AngularSpa/appsettings.json @@ -1,10 +1,15 @@ { "Logging": { "IncludeScopes": false, - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" + "Debug": { + "LogLevel": { + "Default": "Warning" + } + }, + "Console": { + "LogLevel": { + "Default": "Warning" + } } } } diff --git a/templates/AngularSpa/web.config b/templates/AngularSpa/web.config deleted file mode 100644 index a8d6672..0000000 --- a/templates/AngularSpa/web.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/templates/AureliaSpa/AureliaSpa.csproj b/templates/AureliaSpa/AureliaSpa.csproj index 11c64e1..83fa7d3 100644 --- a/templates/AureliaSpa/AureliaSpa.csproj +++ b/templates/AureliaSpa/AureliaSpa.csproj @@ -1,20 +1,20 @@ - + + netcoreapp2.0 true - false + $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; + - - + - - + - - + + @@ -30,4 +30,5 @@ + \ No newline at end of file diff --git a/templates/AureliaSpa/ClientApp/app/components/navmenu/navmenu.html b/templates/AureliaSpa/ClientApp/app/components/navmenu/navmenu.html index 38b97f9..a604b7e 100644 --- a/templates/AureliaSpa/ClientApp/app/components/navmenu/navmenu.html +++ b/templates/AureliaSpa/ClientApp/app/components/navmenu/navmenu.html @@ -9,7 +9,7 @@ - Aurelia + WebApplicationBasic