Interface IDocumentUrlAliasService
Defines operations for handling document URL aliases (umbracoUrlAlias property).
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IDocumentUrlAliasService
Methods
View SourceCreateOrUpdateAliasesAsync(Guid)
Creates or updates the aliases for a single document.
Declaration
Task CreateOrUpdateAliasesAsync(Guid documentKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | documentKey | The document key. |
Returns
| Type | Description |
|---|---|
| Task |
CreateOrUpdateAliasesWithDescendantsAsync(Guid)
Creates or updates the aliases for a document and its descendants.
Declaration
Task CreateOrUpdateAliasesWithDescendantsAsync(Guid documentKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | documentKey | The document key. |
Returns
| Type | Description |
|---|---|
| Task |
DeleteAliasesFromCacheAsync(IEnumerable<Guid>)
Deletes all aliases from the cache for a collection of document keys.
Declaration
Task DeleteAliasesFromCacheAsync(IEnumerable<Guid> documentKeys)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Guid> | documentKeys | The collection of document keys. |
Returns
| Type | Description |
|---|---|
| Task |
GetAliasesAsync(Guid, string?)
Gets all URL aliases for a given document.
Declaration
Task<IEnumerable<string>> GetAliasesAsync(Guid documentKey, string? culture)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | documentKey | The document key. |
| string | culture | The culture code (null for default language). |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<string>> | All aliases for the document in the specified culture, or empty if none found. |
GetDocumentKeysByAliasAsync(string, string?)
Gets all document keys that match a given URL alias.
Declaration
Task<IEnumerable<Guid>> GetDocumentKeysByAliasAsync(string alias, string? culture)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias | The URL alias (normalized: lowercase, no leading slash). |
| string | culture | The culture code (null for invariant). |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<Guid>> | All document keys that have the specified alias, or empty if none found. |
HasAny()
Checks whether any aliases are cached.
Declaration
bool HasAny()
Returns
| Type | Description |
|---|---|
| bool |
|
InitAsync(bool, CancellationToken)
Initializes the service and ensures the alias cache is populated from the database.
Declaration
Task InitAsync(bool forceEmpty, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | forceEmpty | Forces an early return when we know there are no aliases (i.e. on install). |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
RebuildAllAliasesAsync()
Rebuilds all URL aliases from the database.
Declaration
Task RebuildAllAliasesAsync()
Returns
| Type | Description |
|---|---|
| Task |
Remarks
This method clears the existing alias cache and database records, then rebuilds from the umbracoUrlAlias property values on all documents.