November Happy Hour will be moved to Thursday December 5th.

BUG: IUrlResolver.GetUrl NullReferenceException

Vote:
 

Hi,

Tested in v10.9.1 - v11.3.0.0 

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

Having inspected the stack trace and the EPiServer dll's in Reflector, these calls invoke the extension methods within UrlResolverExtensions, ultimately executing the explicit interface implementation on UrlResolver with a null value for the parameter urlResolverArguments:

IUrlResolver.GetUrl(ContentReference contentLink, string language, UrlResolverArguments urlResolverArguments)

Which in turn calls the overload:

GetUrl(ContentReference contentLink, string language, VirtualPathArguments virtualPathArguments)

However when IUrlResolver.GetUrl implementation constructs a VirtualPathArguments object, passing a null value to the constructor, results in a NullReferenceException.

Steps to replicate:

  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:

  1. Replace usage of IUrlResolver with abstract UrlResolver

Thanks,

Stephen

#186919
Edited, Jan 08, 2018 18:14
Vote:
 

Thanks for reporting and for the detailed explination. I have reported a bug with id CMS-9578 for it

#187547
Jan 25, 2018 16:13
Vote:
 

Mr Myers, cannot reproduce in EPiServer.CMS 11.5.0 not sure if the issue has been resolved. 

Starting to wonder if it's something to do with your base build, maybe in the area where absolute url's are forced.

If you can still reproduce with latest EPiServer I think the problem could live elswhere.

Edit: Never mind - it was marked resolved in EPiServer.CMS.Core 11.3.3 in https://world.episerver.com/support/Bug-list/bug/CMS-9578

#190905
Edited, Apr 18, 2018 16:13
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.