public class ServiceUrlProvider : DefaultUrlProvider
{
public override string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
{
var content = umbracoContext.ContentCache.GetById(id);
if (content.DocumentTypeAlias == "Service" && content.Parent != null)
{
// Get the last part of the url
var currentUrl = content.Url;
var splitSections = currentUrl.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
return string.Concat("/",splitSections.Last(), "/");
}
return base.GetUrl(umbracoContext, id, current, mode);
}
}
But I just keep getting the StackOverFlow exception... ?
IUrlProvider - Cannot evaluate expression because the current thread is in a stack overflow state
I have implemented an IUrlProvider to change a node url, but now I can't run the site and when I debug I get the following error?
Anyone else had this with an IUrlProvider?
Should have said I am registering it like so
Can you post the code for the UrlProvider? The issue appears to be there I think.
I have just changed it and still get the same error. I have this in application starting.
And this is my ServiceUrlProvider
But I just keep getting the StackOverFlow exception... ?
Is it by any chance thaat
is recursively calling your service?
Thanks
Carl.
Well this is awkward lol. Thanks Carl. I thought I had changed that to
But too blindly changing things!! Thanks.
I think that Carl is correct, I would replace it with
is working on a reply...