Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "Creating a new decoupled CMS Website" docs #14247

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't have to be, updating to net7.0 is fine, there is no reason to have two, even more in a sample.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rolled it back

</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();
MikeAlhayek marked this conversation as resolved.
Show resolved Hide resolved

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