Try our conversational search powered by Generative AI!

Using IUrlResolver.GetUrl(ContentReference contentLink) generates null reference exception

Found in

EPiServer.CMS.Core 11.1.0

Fixed in

EPiServer.CMS.Core 11.3.3

(Or a related package)

Created

Jan 25, 2018

Updated

Feb 02, 2018

Area

CMS Core

State

Closed, Fixed and tested


Description

When using an IUrlResolver interface abstraction, making a call to GetUrl(IContentReference) or GetUrl(IContent) results in a NullReferenceException.

Steps to reproduce:

  1. Within a class in an episerver project, get an instance of IUrlResolver from the IoC container (constructor injected or via DependencyResolver / ServiceLocator).
  2. Make a call to GetUrl passing in a ContentReference or a IContent instance.
  3. NullReferenceException is thrown.

Workaround:
Replace usage of IUrlResolver with abstract UrlResolver

See https://world.episerver.com/forum/developer-forum/Problems-and-bugs/Thread-Container/2018/1/bug-iurlresolver-geturl-nullreferenceexception/