Hi,
We're running into an issue with a custom URL provider. The provider itself is simple, looking for "Country" (2 letter code) and "State" (2 letter code) to add "/us/california" to the URL instead of "&country=us&state=ca". It takes no parameters.
It all works fine when it's applied to a single page, but when I apply this to 2 different pages, both the frontend and backend become broken. I have to go through SSMS and delete one of the references to it. (check attachment for error)
Does anyone know what I might be doing wrong?
I'm attaching the source code in case anyone wants to take a closer look, but here's the code as well
using System.Collections;
using System.Collections.Generic;
using Dynamicweb.Ecommerce;
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Extensibility.Editors;
using Dynamicweb.Frontend.UrlHandling;
namespace Dna.Winnebago.UrlProvider
{
[AddInName("Country and State")]
[AddInOrder(1000)]
public class CountryAndState : UrlDataProvider, IDropDownOptions
{
public override IEnumerable<UrlDataNode> GetUrlDataNodes(UrlDataNode parent, UrlDataContext dataContext)
{
var nodes = new List<UrlDataNode>();
foreach (var country in Services.Countries.GetCountries())
{
nodes.Add(new UrlDataNode()
{
Id = $"CountryAndState_{country.Code2}",
ParentId = parent.Id,
PathName = $"{country.Code2}",
IgnoreInChildPath = false,
IgnoreParentPath = false,
QueryStringParameter = "Country",
QueryStringValue = country.Code2,
QueryStringExact = string.Empty,
IgnoreParentQuerystring = false
});
foreach (var state in country.Regions)
{
nodes.Add(new UrlDataNode()
{
Id = $"CountryAndState_{country.Code2}_{state.RegionCode}",
ParentId = $"CountryAndState_{country.Code2}",
PathName = $"{state.Name}",
IgnoreInChildPath = false,
IgnoreParentPath = false,
QueryStringParameter = "State",
QueryStringValue = state.RegionCode,
QueryStringExact = string.Empty,
IgnoreParentQuerystring = false
});
}
}
return nodes;
}
public Hashtable GetOptions(string dropdownName)
{
var options = new Hashtable();
return options;
}
}
}
Additionally we noticed something odd. The Url provider only worked after the site recycled. In other words:
- Placed the dll (site recycles automatically)
- Go to page and set the URL provider
- Go to test and does not work
- Recycle the site again (now that it's assigned to the page)
- Perform the same test - it works
I don't seem to have this experience with the Ecom
Thank you
Nuno Aguiar
