From 06a4ef3f996c38c79057bf957f60d6d47e47e2ce Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 31 Aug 2023 08:13:59 -0700 Subject: [PATCH 1/3] Update "Creating a new decoupled CMS Website" docs --- src/docs/guides/decoupled-cms/README.md | 27 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/docs/guides/decoupled-cms/README.md b/src/docs/guides/decoupled-cms/README.md index 47c64dbce03..d6996c14e17 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,27 @@ 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();` +- Remove andy of the following lines if exists in your `Program.cs` file: ```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(); } ``` From bb34b319ddf2c04b1056404c692e44bce0f6aec6 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 31 Aug 2023 08:17:57 -0700 Subject: [PATCH 2/3] cleanup --- src/docs/guides/decoupled-cms/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docs/guides/decoupled-cms/README.md b/src/docs/guides/decoupled-cms/README.md index d6996c14e17..1ecceeb999a 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;net7.0 + net6.0;net7.0 ``` @@ -85,7 +85,7 @@ builder.Services.AddOrchardCms(); - Edit the `Program.cs` file - Add `app.UseOrchardCore();` -- Remove andy of the following lines if exists in your `Program.cs` file: +- If any of the following lines exists in your `Program.cs` file, remove them: ```csharp builder.Services.AddRazorPages(); From c5a28543d2c50a6adcb3e46abe69f1428f94f94f Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 31 Aug 2023 09:19:42 -0700 Subject: [PATCH 3/3] adding a sample --- src/docs/guides/decoupled-cms/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/docs/guides/decoupled-cms/README.md b/src/docs/guides/decoupled-cms/README.md index 1ecceeb999a..d17aa2e5834 100644 --- a/src/docs/guides/decoupled-cms/README.md +++ b/src/docs/guides/decoupled-cms/README.md @@ -105,6 +105,28 @@ builder.Services.AddOrchardCms(); } ``` +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(); + } +} +``` + Start the application, the Setup screen shows up: ![Setup](images/setup.jpg)