Search Results for

    Show / Hide Table of Contents
    View Source

    Class PreviewService

    Provides functionality for managing content preview mode.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public class PreviewService : IPreviewService
    Remarks

    Preview mode allows backoffice users to view unpublished content changes as they would appear on the front-end website. This implementation uses secure cookies with SameSite=None to support cross-site preview scenarios.

    Constructors

    View Source

    PreviewService(ICookieManager, IPreviewTokenGenerator, IServiceScopeFactory, IRequestCache)

    Initializes a new instance of the PreviewService class.

    Declaration
    public PreviewService(ICookieManager cookieManager, IPreviewTokenGenerator previewTokenGenerator, IServiceScopeFactory serviceScopeFactory, IRequestCache requestCache)
    Parameters
    Type Name Description
    ICookieManager cookieManager

    The cookie manager for handling preview cookies.

    IPreviewTokenGenerator previewTokenGenerator

    The generator for creating and validating preview tokens.

    IServiceScopeFactory serviceScopeFactory

    The factory for creating service scopes.

    IRequestCache requestCache

    The request cache for caching preview state per request.

    Methods

    View Source

    EndPreviewAsync()

    Exits preview mode for the current request.

    Declaration
    public Task EndPreviewAsync()
    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    IsInPreview()

    Determines whether the current request is in preview mode.

    Declaration
    public bool IsInPreview()
    Returns
    Type Description
    bool

    true if the current request is in preview mode; otherwise, false.

    View Source

    TryEnterPreviewAsync(IUser)

    Enters preview mode for a given user.

    Declaration
    public Task<bool> TryEnterPreviewAsync(IUser user)
    Parameters
    Type Name Description
    IUser user

    The user entering preview mode.

    Returns
    Type Description
    Task<bool>

    true if preview mode was entered successfully; otherwise, false.

    View Source

    TryGetPreviewClaimsIdentityAsync()

    Attempts to get the claims identity for the current preview session.

    Declaration
    public Task<Attempt<ClaimsIdentity>> TryGetPreviewClaimsIdentityAsync()
    Returns
    Type Description
    Task<Attempt<ClaimsIdentity>>

    An attempt containing the claims identity if in preview mode; otherwise, a failed attempt.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX