---
title: Displaying page content
related:
  - https://docs.kentico.com/k12sp/developing-websites/retrieving-content-in-mvc-applications/displaying-page-attachments.md
  - https://docs.kentico.com/k12sp/custom-development/working-with-pages-in-the-api.md
  - https://docs.kentico.com/k12sp/managing-users/configuring-permissions/configuring-page-permissions/page-level-permissions-acls/checking-page-permissions.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

To retrieve content from individual [content-only](https://docs.kentico.com/k12sp/developing-websites/defining-website-content-structure/creating-and-configuring-page-types/creating-content-only-page-types.md) pages in your MVC application, use the [generated](https://docs.kentico.com/k12sp/developing-websites/generating-classes-for-kentico-objects.md) strongly typed classes provided by the system for each page type. You can use the retrieved page content to populate prepared view models and then display them in your views.

Generated provider classes facilitate the retrieval of individual pages of the corresponding page type. The following example demonstrates the use of a provider class generated for a sample _Article_ page type:

```csharp

// Gets the specified articles using the generated provider
IEnumerable<Article> articles = ArticleProvider.GetArticles()
    .OnSite("MySite")
    .Culture("en-US")
    .Path("/Articles/", PathTypeEnum.Children);

// Gets the published version of a single article using the generated provider
Article article = ArticleProvider.GetArticle(nodeGuid, "en-US", "MySite");

```

By default, the generated code returns published versions of pages. If you need to retrieve the latest edited version of a page, use the following approach:

```csharp

// Gets the latest version of a single article using the generated provider
Article article = ArticleProvider.GetArticle(nodeGuid, "en-US", "MySite")
    .LatestVersion()
    .Published(false);

```

To filter the retrieved pages, use any of the query parameters for single page types type listed in [Reference - DocumentQuery methods](https://docs.kentico.com/k12sp/custom-development/working-with-pages-in-the-api/reference-documentquery-methods.md).

> **Tip:** **Tip**: Optimize the performance of your website by [caching the retrieved page data](https://docs.kentico.com/k12sp/configuring-kentico/configuring-caching/caching-on-mvc-sites.md).

> **Info:** **Automatic URL resolving**
>
> The system provides page output filtering functionality that automatically resolves all virtual relative URLs to their absolute form. The URLs are processed on the side of the MVC application, based on the environment where the site is actually running.
>
> This filter ensures that links added by content editors into page content work correctly, even if you do not explicitly handle URL resolving in your code.

## Working with retrieved page data

You can access the data of a retrieved page through the properties of the object. The following types of page data are available:

- Page fields – the data that is editable on a page's _Content_ tab.
- General page data – properties available for all pages (via the _TreeNode_ class). For example identifiers, values indicating the position in the content tree, etc.
- Metadata – data like the _page title_ and _page keywords._
- Page attachments – stored in fields with the _File_ or _Attachments_ data type. For information about retrieving page attachments, see [Displaying page attachments](https://docs.kentico.com/k12sp/developing-websites/retrieving-content-in-mvc-applications/displaying-page-attachments.md).

```csharp title="Example"

// Retrieves a specific page
News news = NewsProvider.GetNews(nodeGuid, "en-US", "MySite");

// Accesses the ID of the page's parent node in the content tree
int parentNodeId = news.NodeParentID;

// Accesses the 'DocumentPageTitle' metadata field
string pageTitle = news.DocumentPageTitle;


```

### Accessing page field data

The fields available on a page's _Content_ tab are specific to its [Page type](https://docs.kentico.com/k12sp/developing-websites/defining-website-content-structure/creating-and-configuring-page-types.md). You can see the fields that each page type uses:

- In **Page types** (application)\*->_edit page type_->\***Fields** tab
- In the corresponding _\__ database table

We recommend accessing specific fields of a page type via the _Fields_ property:

```csharp

// Retrieves a specific page
News news = NewsProvider.GetNews(nodeGuid, "en-US", "MySite");

// Accesses the 'Title' field
string title = news.Fields.Title;

// Accesses the 'Text' field
string text = news.Fields.Text;

```

> **Note:** **Resolving HTML tags and relative URLs**
>
> Fields which are populated by the **Rich text editor** form control may contain HTML tags and relative links. To ensure that the content is displayed correctly, use one of the following methods in your views:
>
> - The standard **Html.Raw** method, which disables HTML encoding for the values.
> - The **Html.Kentico().ResolveUrls** extension method, which disables HTML encoding for the values and additionally resolves relative URLs to their absolute format. By default, relative URLs are automatically resolved by a filter that processes the output of all pages. You can use the _ResolveUrls_ method to minimize the output filtering requirements or if you wish to disable the filter completely (via the _CMSMVCResolveRelativeUrls_ web.config key).
>
> ```csharp
>
> @Html.Raw(Model.<Rich text field content>)
> @Html.Kentico().ResolveUrls(Model.<Rich text field content>)
>
> ```
