Skip to content

Commit be25b3e

Browse files
committed
Added disclaimer about ASP.NET Core 6's new minimal hosting model
With ASP.NET Core 6's new minimal hosting model, these configurations will no longer be placed in `Startup`'s `ConfigureSerices()` or `Configure()` methods, but instead within `Program` as top-level statements. For now, we're keeping the historical context in the actual code examples, since the context should be comparatively obvious for anyone using the minimal hosting model.
1 parent 40d0b57 commit be25b3e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

OnTopic.AspNetCore.Mvc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public class Startup {
116116
```
117117
> *Note:* This will register the `TopicViewLocationExpander`, `TopicViewResultExecutor`, `TopicRouteValueTransformer`, as well as all [Controllers](#controllers) that ship with `OnTopic.AspNetCore.Mvc`.
118118
119+
> *Note:* When using ASP.NET Core 6's minimal hosting model, this will instead be placed in the `Program` class as a top-level statement.
120+
119121
In addition, within the same `ConfigureServices()` method, you will need to establish a class that implements `IControllerActivator` and `IViewComponentActivator`, and will represent the site's _Composition Root_ for dependency injection. This will typically look like:
120122
```csharp
121123
var activator = new OrganizationNameActivator(Configuration.GetConnectionString("OnTopic"))
@@ -151,6 +153,8 @@ public class Startup {
151153
```
152154
> *Note:* Because OnTopic relies on wildcard path names, a new route should be configured for every root namespace (e.g., `/Web`). While it's possible to configure OnTopic to evaluate _all_ paths, this makes it difficult to delegate control to other controllers and handlers, when necessary. As a result, it is recommended that each root container be registered individually.
153155
156+
> *Note:* When using ASP.NET Core 6's minimal hosting model, these will instead be placed in the `Program` class as a top-level statement.
157+
154158
### Composition Root
155159
As OnTopic relies on constructor injection, the application must be configured in a **Composition Root**in the case of ASP.NET Core, that means a custom controller activator for controllers, and view component activator for view components. For controllers, the basic structure of this might look like:
156160
```csharp
@@ -184,6 +188,9 @@ public class Startup {
184188
}
185189
}
186190
```
191+
192+
> *Note:* When using ASP.NET Core 6's minimal hosting model, these will instead be placed in the `Program` class as a top-level statement.
193+
187194
The first three of these options all use the `Http()` action, which will provide the following fallback logic:
188195
- If `Error:{errorCode}` exists, use that (e.g., `Error:404`)
189196
- If `Error:{errorCode/100*100} exists, use that (e.g., `Error:400`)

0 commit comments

Comments
 (0)