Sitefinity ASP.NET Core Renderer provides context data through the RequestContext and IRenderContext services.
RequestContext
IRenderContext
The IRequestContext interface holds information regarding:
IRequestContext
To access it in the ViewComponents, you must inject it in the constructor. For more information, see Access context information sample on Sitefinity GitHub repository.
ViewComponents
Additionally, the current user object is synced to the httpContext.User property and the CurrentLanguage property is synced with the Thread.CurrentUICulture property.
httpContext.User
CurrentLanguage
Thread.CurrentUICulture
The current user profile is exposed through a web method and the custom fields assigned to it are also available. The current user profile returns the following fields:
The main purpose of the current language property is to hold the language version of the page that is currently being rendered.
You can use it in the following cases:
The current page object is provided in the IRequestContext interface, containing all fields that are not related data fields.
You can access them by injecting the IRequestContext object through a dependancy injection and accessing the fields with the GetValue method that is part of Sitefinity REST SDK.
GetValue
For more information, see REST SDK » The SdkItem class and ISdkItem interface on Sitefinity GitHub repository.
If you want to fetch and access related data items of the page object, you must make a query to Sitefinity CMS using the REST SDK. For more information, see Default.cshtml of the Accessing context information sample on Sitefinity GitHub Repository.
You can use the current site object for contextual information, depending on the requirements of the widgets. One such example is the Language selector widget, linked above.
For more information, see the Language selector widget sample on Sitefinity GitHub repository.
The IRenderContext interface holds two properties and one method:
IsEdit
IsPreview
IsLive()
These properties are useful for showing contextual information in edit mode, when an actual representation of the widget cannot be rendered. For more information, see the Conditional rendering in editor sample on Sitefinity GitHub repository.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important