Get CMS content using content reference ID
To get CMS content from Episerver using content reference ID anywhere in the MVC application using below code.
var contentReference = new ContentReference(163);
var pageRouteHelper = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>().Get<RegistrationPage>(contentReference);
var model = new CMSPageModel<RegistrationPage, RegisterViewModel>(pageRouteHelper);
model.ViewModel = new RegisterViewModel();
Now you can use this model.ViewModel object to render CMS content in MVC view
Comments