From f36baa84690a7c5ad7d73570a7151b66fd7beb63 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 31 Aug 2023 14:37:03 -0700 Subject: [PATCH] Update "Creating a new decoupled CMS Website" docs (#14247) --- src/docs/guides/decoupled-cms/README.md | 49 ++++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/src/docs/guides/decoupled-cms/README.md b/src/docs/guides/decoupled-cms/README.md index 47c64dbce03..d17aa2e5834 100644 --- a/src/docs/guides/decoupled-cms/README.md +++ b/src/docs/guides/decoupled-cms/README.md @@ -59,7 +59,7 @@ The newly created website should be able to run, and look like this: ```xml - net6.0 + net6.0;net7.0 ``` @@ -81,18 +81,49 @@ builder.Services.AddOrchardCms(); ``` !!! warning "Razor Pages" - `AddRazorPages` must not be called directly as `services.AddOrchardCms()` already invokes it internally. + `builder.Services.AddRazorPages()` must not be called directly as `builder.Services.AddOrchardCms()` already invokes it internally. - Edit the `Program.cs` file -- Remove everything after `app.UseStaticFiles();` and replace it by `app.UseOrchardCore();` like this: +- Add `app.UseOrchardCore();` +- If any of the following lines exists in your `Program.cs` file, remove them: ```csharp - ... - - app.UseHttpsRedirection(); - app.UseStaticFiles(); - - app.UseOrchardCore(); + builder.Services.AddRazorPages(); + + if (!app.Environment.IsDevelopment()) + { + app.UseExceptionHandler("/Error"); + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseRouting(); + + app.UseAuthorization(); + + app.MapRazorPages(); +} +``` + +Here is a sample of a bare minimum `Program.cs` file + +```csharp +public class Program +{ + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + // Add services to the container. + builder.Services.AddOrchardCms(); + + var app = builder.Build(); + + app.UseStaticFiles(); + app.UseOrchardCore(); + + app.Run(); + } } ```