UDI Identifiers
umb://document/4fed18d8c5e34d5e88cfff3a5b457bf2. Format
Usage
Retrieving Content by UDI
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Models
@inject IContentService contentService
@{
// Define the UDI string here
var udiString = "umb://document/334cadfa62dd49049aad86b6e4c02aac"; // Example UDI string
if (udiString.StartsWith("umb://document/"))
{
// Extract the GUID from the UDI string
var guidString = udiString.Replace("umb://document/", "");
if (Guid.TryParse(guidString, out var guid))
{
// Retrieve the content by GUID
var content = contentService.GetById(guid);
if (content != null)
{
// Access the body text field
var bodyText = content.GetValue<string>("bodyText"); // Replace 'bodyText' with the alias of your body text field
<p>@bodyText</p> // Output the body text
}
else
{
<p>Content not found.</p>
}
}
else
{
<p>Invalid GUID in the UDI string.</p>
}
}
}UDI Types
GUID UDI
String UDI
Last updated
Was this helpful?