Skip to content

Commit

Permalink
Update "Creating a new decoupled CMS Website" docs (#14247)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Aug 31, 2023
1 parent 54cf555 commit f36baa8
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions src/docs/guides/decoupled-cms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The newly created website should be able to run, and look like this:

```xml
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>
```

Expand All @@ -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();
}
}
```

Expand Down

0 comments on commit f36baa8

Please sign in to comment.