# Access context data

## Overview

Sitefinity ASP.NET Core Renderer provides context data through the `RequestContext` and `IRenderContext` services.

## IRequestContext

The `IRequestContext` interface holds information regarding:

* Current user
* Current site
* Current language
* Page layout
* Current page

To access it in the `ViewComponents`, you must inject it in the constructor.\
For more information, see [Access context information](https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/tree/master/src/accessing-context-information) sample on Sitefinity GitHub repository.

Additionally, the current user object is synced to the `httpContext.User` property and the `CurrentLanguage` property is synced with the `Thread.CurrentUICulture` property.

## Current user

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:

* Short text
* Long text
* Yes / No
* Date and Time
* Number
* Taxonomies

## Current language

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:

* To localize content\
  For more information, see [Localization](https://www.progress.com/documentation/sitefinity-cms/localization-net-core).
* To build a language selector.\
  For more information, see the [Language selector widget](https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/tree/master/src/language-selector) sample on Sitefinity GitHub repository.

## Current page

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.

For more information, see [REST SDK](https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/blob/master/RestSDK.md) » *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](https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/blob/master/src/accessing-context-information/Views/Shared/Components/ContextDemo/Default.cshtml) of the *Accessing context information* sample on Sitefinity GitHub Repository.

## Current site

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](https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/tree/master/src/language-selector) sample on Sitefinity GitHub repository.

## IRenderContext

The `IRenderContext` interface holds two properties and one method:

* `IsEdit`\
  Used to check whether the current request is executing in the page editor.
* `IsPreview`\
  Used to check whether the current request is executing in the page preview.
* `IsLive()`\
  Used to check whether the current request is executing when browsing the live site.

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](https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/tree/master/src/conditional-rendering-in-editor) sample on Sitefinity GitHub repository.
