We are using hierarchial URLs for our CMS/Commerce site, but we would like to start using the SEOUris as well. For some reason though they always render an error message on the first visit.
Here is an example of an exception:
Error occuredUser IPUser AgentUrlReferer
I'm experiencing the exact same problem for this issue. Were you ever able to find a solution for it or was it fixed by Epi? For some reason the products don't load the first time (it seems to be only some of them though, though I cannot confirm that is the exact behavior). Also, the root categories we have seem to also through a similar exception when loading but children categories do not (probably caused by the seo url again).
I've seen this problem with another customer, however without more information we don't know what is wrong. Please contact our developer support service for further assistance.
It seems that there is an issue with the SEO Uri when loading the product or category the first time. Here are some screen shots of what is happening.
When trying to go to https://domain.com/bed-bath I get the following two types of errors depending on what the name in the url is.
Exception Details: EPiServer.Core.TypeMismatchException: The routed data is of type 'Models.Catalog.CategoryNode' and the binding context data 'currentPage' is of type 'Models.Catalog.CategoryNode', neither of which matches the requested type 'Models.Pages.PageBase'.
I reload the page again with the same information and I receive the following error:Exception: EPiServer.Core.TypeMismatchException: Content with id '37' is of type 'Castle.Proxies.HomePageProxy' which does not inherit required type 'EPiServer.Commerce.Catalog.ContentTypes.CatalogContentBase'
However, when I change the name in url to the following, the page works if I load https://domain.com/bed-bath2, but still doesn't if I load the original link.
It appears that I received the same error when going to the product for the very first time as well with the seo uri but then it loads fine after that.I am also trying to use the contentViewModelFactory as found in this post.
I would suggest you to use Quicksilver as a sample/starting point for MVC approach. The post from Jonas is old and some parts of it might be outdated.
Regarding the issue, it seems like you have a page (Id = 37) has the name in url as "bed-bath". So check this
and look at Name in Url property
Unfortunately I think we are far enough into the project that we can't change out the mechanism easily at this point. Perhaps a future change will do it (unless we find we can't resolve the loading issue). The error that I listed is actually fixed now as I found it was related with trying to load the breadcrumb we have where the parent content reference was of type Homepage for our root categories, and we were trying to convert it to Get<CatalogContentBase>(contentReference) and it was throwing the type mismatch error. I updated the code so now it does Get<IContent>(contentReference) as CatalogContentBase which does the conversion just fine and then I check for a null value to continue to execute the code or not.
I am still having an issue where the first time a product or category loads it throws the first error I mentioned, but that seems to be related to the seo uri that is being used and an issue with it loading on the first run. It doesn't seem like it happens with all proiducts though, so I am going to try and determine what the difference between products are to see if perhaps that is the issue.
I can confirm that we are still having this issue where the SEO URIs do not work on the first load but they do work on all subsequent loads.
They all throw a TypeMismatch exception on the first load like this:
TypeMismatchException: The routed data is of type 'Piab.CMS.Models.Commerce.InRiverChannelNode' and the binding context data 'currentPage' is of type 'Piab.CMS.Models.Commerce.InRiverChannelNode', neither of which matches the requested type 'Piab.CMS.Models.Pages.SitePageData'.
But after pressing F5 to reload the page it always works until the site restarts again.
We are not using the SEO URIs for anything yet but for some unexplainable reason Google webmaster tools reports finding these pages every now and again and finding server error 500 being reported on them.
I usually update to the latest EPiServer versions within 1-2 weeks of their release but now we're currently running CMS 9.12.2 and Commerce 9.24.1 since I've been in a big project with a huge website update running behind schedule and previous experiences with EPiServer updates frequently breaking things have made me hold off during this project. I should be able to update to the latest EPiServer 10 soon though and I can report here again if this issue gets resolved by that update or not.
If it's anyhow related I think we're also using the ContentViewModelFactory from Jonas (our website is based on the very first EPiServer 7 MVC Allow templates project), although it has been modified quite a bit by me at this point.
But no, unfortunately I have not found a solution to this yet and since there is still no intention from our marketing department of wanting to use the SEO uris I consider this to be a very low priority issue and I haven't actively been looking for a solution. I just threw this post out there too see if others have been experiencing the same, which do seem to be the case.
I am using the same ContentViewModelFactory from Jonas as well and I am using version 10.3 and I am still getting the error, so it doesn't seem to be fixed in the newer versions.
Unless you plan on using the same category / product url no matter what category the product is in (meaning there is one joint url you always point back to for each product), then you will likely need to get the SEO urls working for your canonical tags, otherwise you may see a split in traffic by the web crawlers that could lower your page rank.
Thanks for the tip Steven. We do have products in several categories sometimes on our page but our canonical URL is just the first hierachial URL, it's not based on the SEO URI.Here's one example:https://www.piab.com/Products/suction-cups/shape/flat/pigrip-configurable-suction-cups/ <-- Canonical URLhttps://www.piab.com/Products/suction-cups/application/bag-handling/pigrip-configurable-suction-cups/
Both pages render the first URL as the canonical one. This product actually exists in 10+ locations. We rather show this URL to Google than our weird SEO uri which is often just a number and something we thought was required for our PIM integration (but it actually seems to not be, not anymore at least).
Even the SEO uri of this page: https://www.piab.com/176 renders the first URL in this post as the canonical one so this should not be a problem. The weird thing is that Google webmaster tools finds these SEO URLs every now and again and complain that they don't work when it first loads them. I have not been able to find any place on the webpage that renders a URL with the SEO URI. It could be a really old bug perhaps from our sitemaps but Google refuses to forget these URLs, I don't know. When I look at the place the incorrect URL was found on and manually view the source I never actually find it there either...
Hello now I can also confirm that this issue still happens with EPiServer CMS 10.9.0 with EPiServer Commerce 10.5.1. This is what the error looks like. As you can see there's nothing in the error stacktrace from our project. It's all standard .NET and then it fails in EPiServer.Web.Mvc.Internal.ContentDataModelBinder.BindModel. After refreshing the URL the problem always disappears.