-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breadcrumbs #212
Comments
If you are using v4, this would be the first complaint we have had about such an issue. Please post your routes, Mvc.sitemap XML, and MvcSiteMapProvider settings from the web.config so we can get some idea how it is configured. If you are still using v3, this has been reported several times already and is due to the old caching model, which has now been replaced. Upgrading to v4 will probably fix it. |
We're using v4. Here the requested files: Routes: routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Mvc.sitemap XML:
MvcSiteMapProvider settings: |
Nothing stands out as being configured wrong in your settings. The current node will be null in the case where you navigate to a page and no match is found in your sitemap. This will cause the SiteMapPath to disappear. If this is the case, it definitely won't be random - it will always happen when you navigate to that URL, and navigating to a URL that causes a match will cause it to reappear. Could you check whether that is the case? I take it you have upgraded from v3 based on your advanced configuration. There is a bug that was fixed that will cause MvcSiteMapProvider to behave differently than its predecessor. The preserved route parameters used to be written to the shared cache. This caused MvcSiteMapProvider to remember the parameter value across requests, but also meant that if another user requested the value it would be overwritten by the new user. This has been fixed - the value is written to the request cache, but also means that these preserved route parameters are not remembered on subsequent requests. Have a look at #207 for an example of how to fix this. |
Thanks for your suggestions but we checked and it's not that case. |
We changed a xml row to We removed the ID from the preservedRouteParameters because it's not used by the action and now after 10 minutes the breadcrumbs never diseappears. Could it be that the problem? |
That could cause the problem if you also have an "id" in the current request that doesn't really belong in the node to produce the match. PreservedRouteParameters will always copy all of the values in the list from the current request if they exist. And if the extra parameter causes the match not to occur, it will cause the current node to be null and the breadcrumb to disappear. It also could explain why it is intermittent, as you might be getting some URLs built with an "id" and some without, and are getting a cascading effect when switching back and forth. I think that rather than theorizing about the issue, you should setup debugging of MvcSiteMapProvider so you can step through the code and analyze what is happening. The best place to start would be the MatchesRoute method to see what is in the RouteValues dictionary and what is in the passed in route values of the current request when the match doesn't occur on the node that should be the current node. Or, if you could build a small demo project that reproduces the issue and either post it on GitHub or zip it and make it available for download, I could take a look. Please provide instructions what I need to do to make the problem appear if you go this route. |
I'll try to setup debugging in the next days... at moment it seems to work great! :) thanks for helping! |
Alright. I suspect the difference you were seeing is due to the fact that it no longer persists route values across requests - that explains why the behavior changed for the better when you removed the "id". But since we had at least 3 other complaints of configurations like this not working correctly, I have added a session caching option for RouteValues. According to Maarten, the persistent caching of the RouteValues was an unintended side effect of the preservedRouteParameters and SiteMapPreserveRouteDataAttribute features, so the default will be to use the request cache. That is, session caching will be disabled by default. The session caching will depend on ASP.NET session state by default but you will be able to create a small custom class to return a user id string that is stored in a cookie or other location if preferred (similar to ITempDataProvider). |
I have a similar problem. To reproduce please follow these steps:
Now if you hit /Home/About some random GUID is shown in the breadcrumb. That's OK. If you restart IIS (Express), and hit /Home/About/1 a GUID is shown, but if you hit /Home/About/2 or /Home/About breadcrumb does not exist. Seems to be some caching issue. Any idea how to resolve this problem? |
You are not getting a match on /Home/About/1 the first time because you do not have an action parameter on your About method and you made no mention of putting the In your sitemap you have:
And in your route you have:
This is not a match. To make it match you need to have an id in the sitemap side, which can be done by making a node that includes it or by using preservedRouteParameters to force every id to match a single node (it actually copies the value from the route of the current request). Please review Routing Basics. The second case I have confirmed is a bug - the preserved route parameters are not being ignored when the sitemap is being built, therefore the values are being added to the permanent cache rather than the request cache. This may be related to the behavior that @cicciopage was seeing. Thanks for giving me a reliable way to reproduce the behavior. I will be rolling this into a patch that will be released within a few hours. |
…tten to shared cache. Also fixes recursion issue where route values are being copied from the current request multiple times.
Ok, the fix is now live in v4.0.17. Versioning is still messed up, though - I am still working with Maarten on that. |
Thanks for the quick fix. |
I suspect your issue was entirely based on the problem I fixed in v4.0.17. For now, I am marking this closed. Feel free to reopen it again if you start seeing similar behavior. Also, you might want to take a look at How to Make MvcSiteMapProvider Remember a User's Position for a detailed look at how the route matching works. |
Sometimes the bredcrumbs is not shown. In that case if I open and save again the mvc.sitemap and relaunch the website the breadcrumbs is shown.
It seems a random problem.
Any suggestions?
Thanks,
Francesco.
The text was updated successfully, but these errors were encountered: