Get the current Sitecore item.

In this How To we look at how to retrieve the current Sitecore Item represented by Sitecore.Context.Item.

Our template has the following two fields:

  • Title - Single Line Text
  • Text - Rich Text

We need to create a model to represent this item:

public class MyModel{
    public virtual string Title { get; set; }

    public virtual string Text { get; set; }


All properties MUST be marked as virtual.

With this model we can request data from Sitecore.

ISitecoreContext service = new SitecoreContext();

MyModel model = service.GetCurrentItem<MyModel>();