I upgraded my dev instance from Sitecore 8.2 to Sitecore 9.3.

My upgrade was successful but I am getting errors when I am trying to access my page.

In our solution for getting the current page, we are using SitecoreContext.

Here my code:

var currentPage = SitecoreContext.GetCurrentItem<BasePage>();

and by using this code on the page I am getting the error, shown in below screenshot

enter image description here

We are using the following glass mapper version

<package id="Glass.Mapper.Sc.93.Core" version="5.8.171" targetFramework="net48" />
<package id="Glass.Mapper.Sc.93.Mvc" version="5.8.171" targetFramework="net48" />

2 Answers 2


As I can see you are using GlassMapper 5 version and in GlassMapper 5 version SitecoreContext, GlassView, GlassController are obsolete. On behalf of SitecoreContext you can Use either IRequestContext, IMvcContext or IWebFormsContext.

Or you can use SitecoreContext as well, by initializing it first then use it.

var objSitecoreContext = new SitecoreContext();
var currentPage = objSitecoreContext.GetCurrentItem<BasePage>();

It will work for you.


GlassMapper functionality was removed from 5.x SitecoreContext. That's why you cannot call sitecoreContext.GetItem anymore. According to Glass Mapper documenation (link below):


should be replaced with


Here you can read about other tips & tricks for upgrading from v4 to v5:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.