getting exception "Object reference not set to an instance of an object." while getting current page

Muhammad Kaleem asked on March 1, 2019 17:30

getting exception "Object reference not set to an instance of an object." while getting current page from an interface as working in dancing goat sample project i have created an interface and declare a property as "LandingPage GetLandingPage(string pageAlias);" and create a parametric constructor and create object of interface in constructor parameter. while getting landingPage it says null reference exception, my pageAlias is not null,

public ActionResult Index(string pageAlias) { var landingPage = mRepository.GetLandingPage(pageAlias); if (landingPage == null) { return HttpNotFound(); } HttpContext.Kentico().PageBuilder().Initialize(landingPage.DocumentID); return View(); }

Recent Answers


Rui Wang answered on March 1, 2019 19:37

Do you have the correct routing for getting the pageAlias? Do you have the right pattern assign to the landing page type in CMS?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.