Catch-All routing with Blazor/OrchardCore De-Coupled CMS. #15781
Replies: 2 comments
-
This is the page I would like to have work. @page "/{*Slug}";
@if(_contentItem is null)
{
<StatusCodeErrorPage StatusCode="@(404)" />
}
else
{
<DynamicComponent Type="_contentItemType" Parameters="_parameters" />
}
@code {
private Dictionary<string, object> _parameters = [];
private ContentItem? _contentItem;
private Type? _contentItemType;
[Parameter]
public string Slug { get; set; }
[Inject]
private IOrchardHelper Orchard { get; init; }
protected override async Task OnParametersSetAsync()
{
_contentItem = await Orchard.GetContentItemBySlugAsync(Slug);
if (_contentItem is null) return;
_parameters["ContentItem"] = _contentItem;
_contentItemType = GetType().Assembly
.GetTypes()
.Where(p => !p.IsAbstract && p.IsSubclassOf(typeof(CsmHostedComponentBase)))
.SingleOrDefault(p => p.Name == _contentItem.ContentType);
StateHasChanged();
}
} Then all my components would be at But, using this, calls to |
Beta Was this translation helpful? Give feedback.
-
Another problem I've found. Because you can't exclude segments, the next obvious thing would be to have multiple whitelisted segments, and then your slug. @page "/prefix-1/{*Slug}";
@page "/prefix-2/{*Slug}";
@page "/prefix-3/{*Slug}";
@inherits RoutedComponentBase;
@code {
[Parameter] public string? Slug { get; set; }
}
<ContentRouter Alias="@NavigationManager.ToBaseRelativePath(NavigationManager.Uri)" /> However, now, going from Is there any way to make this transient, so that it treats the parameters as changed, every single time? |
Beta Was this translation helpful? Give feedback.
-
I'm using a Blazor8 with OrchardCore as a de-coupled CMS. I want
/admin*
to be routed by Orchard, and the rest to be routed by Blazor.Using this as a basic working example: https://github.com/ApacheTech/BlazOrchard
If I have a page with
@page "/{*Slug}";
, I want to give priority to/admin
to run through the MVC Area controller. It seems that Blazor strips all power away from MVC to route itself. I want Blazor to be the fallback.Beta Was this translation helpful? Give feedback.
All reactions