Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jackie Nagel 13 posts 92 karma points
    Oct 14, 2013 @ 12:20
    Jackie Nagel
    0

    NiceUrl always returns # when mocking a UmbracoContext

    Hello

    I'm currently having a hard time getting the NiceUrl of a node retrieved through the ContentService, while in a scope where HttpContext and UmbracoContext is null. Therefore I've mocked an HttpContext and a UmbracoContext to solve this issue, but now I'm just getting # as url for all nodes.

    Any suggestions? :-)

    Kind regards

  • Stephen 767 posts 2273 karma points c-trib
    Oct 14, 2013 @ 12:37
    Stephen
    0

    UrlProvider wants the complete cache available, which means if you're mocking... a good deal of things need to be made available. If you have the Umbraco source, you can look at what's in Umbraco.Web.Standalone...

  • Jackie Nagel 13 posts 92 karma points
    Oct 14, 2013 @ 12:38
    Jackie Nagel
    0

    Thanks, giving it a try :-)

  • Jackie Nagel 13 posts 92 karma points
    Oct 14, 2013 @ 12:56
    Jackie Nagel
    0

    I see. I guess you're referring to InitializeResolvers method in the StandaloneBootManger.cs (https://github.com/umbraco/Umbraco-CMS/blob/6.2.0/src/Umbraco.Web/Standalone/StandaloneBootManager.cs).

    I'm just hitting a wall here, since all of the constructors that I should be using is marked as internal. Is this an incorrect observation or? :-)

    Kind regards.

  • Jackie Nagel 13 posts 92 karma points
    Oct 14, 2013 @ 13:40
    Jackie Nagel
    100

    Alright, problem was that we we're running in a loadbalanced environment and the xmlcache wasn't correctly in sync, so the Umbraco.EnsureContext() works fine.

    Thanks for the help Stephen :-)

Please Sign in or register to post replies

Write your reply to:

Draft