From b61139b485c44990f12c2cb3fc8c8d9702ce7c6e Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Fri, 10 Apr 2020 07:27:30 -1000 Subject: [PATCH 1/5] Razor file compilation (#17709) * Razor file compilation * Razor file compilation * Razor file compilation * Razor file compilation * Apply suggestions from code review Co-Authored-By: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Razor file compilation * Razor file compilation Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> --- aspnetcore/mvc/views/view-compilation.md | 24 ++------ .../views/view-compilation/sample/Startup.cs | 56 +++++++++++++++++++ 2 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 aspnetcore/mvc/views/view-compilation/sample/Startup.cs diff --git a/aspnetcore/mvc/views/view-compilation.md b/aspnetcore/mvc/views/view-compilation.md index efb09a3c3a..c42a7cb701 100644 --- a/aspnetcore/mvc/views/view-compilation.md +++ b/aspnetcore/mvc/views/view-compilation.md @@ -25,7 +25,7 @@ To enable runtime compilation for all environments and configuration modes: 1. Install the [Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation/) NuGet package. -1. Update the project's `Startup.ConfigureServices` method to include a call to `AddRazorRuntimeCompilation`. For example: +1. Update the project's `Startup.ConfigureServices` method to include a call to . For example: ```csharp public void ConfigureServices(IServiceCollection services) @@ -55,29 +55,15 @@ To enable runtime compilation based on the environment and configuration mode: 1. Update the project's `Startup.ConfigureServices` method to include a call to `AddRazorRuntimeCompilation`. Conditionally execute `AddRazorRuntimeCompilation` such that it only runs in Debug mode when the `ASPNETCORE_ENVIRONMENT` variable is set to `Development`: - ```csharp - public IWebHostEnvironment Env { get; set; } - - public void ConfigureServices(IServiceCollection services) - { - IMvcBuilder builder = services.AddRazorPages(); - - #if DEBUG - if (Env.IsDevelopment()) - { - builder.AddRazorRuntimeCompilation(); - } - #endif - - // code omitted for brevity - } - ``` + [!code-csharp[](~/mvc/views/view-compilation/sample/Startup.cs?name=snippet)] ## Additional resources +* [RazorCompileOnBuild and RazorCompileOnPublish](xref:razor-pages/sdk#properties) properties. * * * +* See the [runtimecompilation sample on GitHub](https://github.com/aspnet/samples/tree/master/samples/aspnetcore/mvc/runtimecompilation) for a sample that shows making runtime compilation work across projects. ::: moniker-end @@ -104,4 +90,4 @@ Build-time compilation is supplemented by runtime compilation of Razor files. AS * * -::: moniker-end \ No newline at end of file +::: moniker-end diff --git a/aspnetcore/mvc/views/view-compilation/sample/Startup.cs b/aspnetcore/mvc/views/view-compilation/sample/Startup.cs new file mode 100644 index 0000000000..780b52013b --- /dev/null +++ b/aspnetcore/mvc/views/view-compilation/sample/Startup.cs @@ -0,0 +1,56 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +#region snippet +public class Startup +{ + public Startup(IConfiguration configuration, IWebHostEnvironment env) + { + Configuration = configuration; + Env = env; + } + + public IWebHostEnvironment Env { get; set; } + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + IMvcBuilder builder = services.AddRazorPages(); + +#if DEBUG + if (Env.IsDevelopment()) + { + builder.AddRazorRuntimeCompilation(); + } +#endif + } + + public void Configure(IApplicationBuilder app) + { + if (Env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Error"); + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseStaticFiles(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapRazorPages(); + }); + } +} +#endregion \ No newline at end of file From 6e80fd6b5beb5354377a6f00bdbc0af727f93206 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Fri, 10 Apr 2020 12:41:55 -0500 Subject: [PATCH 2/5] Linux topics ForwardedHeaders middleware update (#17725) --- aspnetcore/host-and-deploy/linux-apache.md | 4 ++-- aspnetcore/host-and-deploy/linux-nginx.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aspnetcore/host-and-deploy/linux-apache.md b/aspnetcore/host-and-deploy/linux-apache.md index 73e8ee2780..7813ef32d9 100644 --- a/aspnetcore/host-and-deploy/linux-apache.md +++ b/aspnetcore/host-and-deploy/linux-apache.md @@ -5,7 +5,7 @@ description: Learn how to set up Apache as a reverse proxy server on CentOS to r monikerRange: '>= aspnetcore-2.1' ms.author: shboyer ms.custom: mvc -ms.date: 02/05/2020 +ms.date: 04/10/2020 uid: host-and-deploy/linux-apache --- # Host ASP.NET Core on Linux with Apache @@ -58,7 +58,7 @@ Because requests are forwarded by reverse proxy, use the [Forwarded Headers Midd Any component that depends on the scheme, such as authentication, link generation, redirects, and geolocation, must be placed after invoking the Forwarded Headers Middleware. As a general rule, Forwarded Headers Middleware should run before other middleware except diagnostics and error handling middleware. This ordering ensures that the middleware relying on forwarded headers information can consume the header values for processing. -Invoke the method in `Startup.Configure` before calling or similar authentication scheme middleware. Configure the middleware to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers: +Invoke the method at the top of `Startup.Configure` before calling other middleware. Configure the middleware to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers: ```csharp // using Microsoft.AspNetCore.HttpOverrides; diff --git a/aspnetcore/host-and-deploy/linux-nginx.md b/aspnetcore/host-and-deploy/linux-nginx.md index d23bcc416c..81d94b716b 100644 --- a/aspnetcore/host-and-deploy/linux-nginx.md +++ b/aspnetcore/host-and-deploy/linux-nginx.md @@ -5,7 +5,7 @@ description: Learn how to setup Nginx as a reverse proxy on Ubuntu 16.04 to forw monikerRange: '>= aspnetcore-2.1' ms.author: riande ms.custom: mvc -ms.date: 02/05/2020 +ms.date: 04/10/2020 uid: host-and-deploy/linux-nginx --- # Host ASP.NET Core on Linux with Nginx @@ -79,7 +79,7 @@ Because requests are forwarded by reverse proxy, use the [Forwarded Headers Midd Any component that depends on the scheme, such as authentication, link generation, redirects, and geolocation, must be placed after invoking the Forwarded Headers Middleware. As a general rule, Forwarded Headers Middleware should run before other middleware except diagnostics and error handling middleware. This ordering ensures that the middleware relying on forwarded headers information can consume the header values for processing. -Invoke the method in `Startup.Configure` before calling or similar authentication scheme middleware. Configure the middleware to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers: +Invoke the method at the top of `Startup.Configure` before calling other middleware. Configure the middleware to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers: ```csharp // using Microsoft.AspNetCore.HttpOverrides; From 6609cee9d66b421861808369f22cfff29b4968ee Mon Sep 17 00:00:00 2001 From: Immo Landwerth Date: Fri, 10 Apr 2020 11:01:17 -0700 Subject: [PATCH 3/5] Fix links to Code of Conduct (#17732) --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 0449dd8609..a71dce3303 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,3 @@ This repository contains the conceptual ASP.NET Core documentation hosted at [do API documentation changes are made in the [AspNetApiDocs repository](https://github.com/dotnet/AspNetApiDocs) against the triple slash `///` comments. ASP.NET 4.x documentation changes are made in the [dotnet/AspNetDocs repository](https://github.com/dotnet/AspNetDocs). - -## Microsoft Open Source Code of Conduct - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. \ No newline at end of file From 57141a39691c4163f55f753b1dbebeaeaabe4f29 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Sun, 12 Apr 2020 09:00:24 -0500 Subject: [PATCH 4/5] Patch SignalR code example (#17754) --- aspnetcore/signalr/configuration.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index c856b904c9..bb6f8a11b9 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -5,7 +5,7 @@ description: Learn how to configure ASP.NET Core SignalR apps. monikerRange: '>= aspnetcore-2.1' ms.author: bradyg ms.custom: mvc -ms.date: 12/10/2019 +ms.date: 04/12/2020 no-loc: [SignalR] uid: signalr/configuration --- @@ -25,7 +25,7 @@ As an example, to configure the serializer to not change the casing of property ```csharp services.AddSignalR() .AddJsonProtocol(options => { - options.PayloadSerializerOptions.PropertyNamingPolicy = null + options.PayloadSerializerOptions.PropertyNamingPolicy = null; }); ``` @@ -1085,4 +1085,4 @@ HubConnection hubConnection = HubConnectionBuilder.create("https://example.com/m * * -::: moniker-end \ No newline at end of file +::: moniker-end From 2cb0d40a66e81df19982c1f27cd55a30d09b16d8 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Sun, 12 Apr 2020 09:01:42 -0500 Subject: [PATCH 5/5] Patch Blazor Layout topic example (#17755) --- aspnetcore/blazor/layouts/sample_snapshot/3.x/App2.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/layouts/sample_snapshot/3.x/App2.razor b/aspnetcore/blazor/layouts/sample_snapshot/3.x/App2.razor index f47bc110d1..f5b47365bf 100644 --- a/aspnetcore/blazor/layouts/sample_snapshot/3.x/App2.razor +++ b/aspnetcore/blazor/layouts/sample_snapshot/3.x/App2.razor @@ -3,7 +3,7 @@ - +

Page not found

Sorry, there's nothing at this address.