Class ApiLink
Represents a link in the Delivery API.
Inheritance
Namespace: Umbraco.Cms.Core.Models.DeliveryApi
Assembly: Umbraco.Core.dll
Syntax
public sealed class ApiLink
Properties
View SourceCulture
Gets or sets the (optional) culture of the link.
Declaration
public string? Culture { get; }
Property Value
| Type | Description |
|---|---|
| string |
DestinationId
Gets the unique identifier of the destination content or media.
Declaration
public Guid? DestinationId { get; }
Property Value
| Type | Description |
|---|---|
| Guid? |
DestinationType
Gets the content or media type alias of the destination.
Declaration
public string? DestinationType { get; }
Property Value
| Type | Description |
|---|---|
| string |
LinkType
Gets the type of the link.
Declaration
public LinkType LinkType { get; }
Property Value
| Type | Description |
|---|---|
| LinkType |
QueryString
Gets the query string of the link.
Declaration
public string? QueryString { get; }
Property Value
| Type | Description |
|---|---|
| string |
Route
Gets the route information for the destination content.
Declaration
public IApiContentRoute? Route { get; }
Property Value
| Type | Description |
|---|---|
| IApiContentRoute |
Target
Gets the target attribute of the link (e.g., "_blank").
Declaration
public string? Target { get; }
Property Value
| Type | Description |
|---|---|
| string |
Title
Gets the title of the link.
Declaration
public string? Title { get; }
Property Value
| Type | Description |
|---|---|
| string |
Url
Gets the URL of the link.
Declaration
public string? Url { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
View SourceContent(string, string?, string?, Guid, string, IApiContentRoute)
Creates a link to content.
Declaration
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
public static ApiLink Content(string title, string? queryString, string? target, Guid destinationId, string destinationType, IApiContentRoute route)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The title of the link. |
| string | queryString | The query string of the link. |
| string | target | The target attribute of the link (e.g., "_blank"). |
| Guid | destinationId | The unique identifier of the destination content. |
| string | destinationType | The content type alias of the destination. |
| IApiContentRoute | route | The route information for the destination content. |
Returns
| Type | Description |
|---|---|
| ApiLink | A new ApiLink instance representing a content link. |
Content(string, string?, string?, Guid, string, IApiContentRoute, string?)
Creates a link to content.
Declaration
public static ApiLink Content(string title, string? queryString, string? target, Guid destinationId, string destinationType, IApiContentRoute route, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The title of the link. |
| string | queryString | The query string of the link. |
| string | target | The target attribute of the link (e.g., "_blank"). |
| Guid | destinationId | The unique identifier of the destination content. |
| string | destinationType | The content type alias of the destination. |
| IApiContentRoute | route | The route information for the destination content. |
| string | culture | The optional culture for the link. |
Returns
| Type | Description |
|---|---|
| ApiLink | A new ApiLink instance representing a content link. |
External(string?, string, string?, string?)
Creates an external link.
Declaration
public static ApiLink External(string? title, string url, string? queryString, string? target)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The title of the link. |
| string | url | The external URL. |
| string | queryString | The query string of the link. |
| string | target | The target attribute of the link (e.g., "_blank"). |
Returns
| Type | Description |
|---|---|
| ApiLink | A new ApiLink instance representing an external link. |
Media(string, string, string?, string?, Guid, string)
Creates a link to media.
Declaration
public static ApiLink Media(string title, string url, string? queryString, string? target, Guid destinationId, string destinationType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The title of the link. |
| string | url | The URL of the media. |
| string | queryString | The query string of the link. |
| string | target | The target attribute of the link (e.g., "_blank"). |
| Guid | destinationId | The unique identifier of the destination media. |
| string | destinationType | The media type alias of the destination. |
Returns
| Type | Description |
|---|---|
| ApiLink | A new ApiLink instance representing a media link. |