-
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
Error with 'PreservedRouteParameters' - v4.6.18 #382
Comments
I don't see any problem with your node configuration. Could you post your routes? The preservedRouteParameters logic was changed slightly in 4.6.18. Could you see if this still happens with 4.6.17? |
In the 4.6.17 also happens. The only routing is public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
} |
You need to change the route as follows: public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
} Setting a default value to "" is not the same as setting it to That said, I don't think it will solve your issue. Are you setting the "id" RouteValue in your MvcSiteMapProvider.Sitemaps.Current.CurrentNode.RouteValues.Add("id", 1234); If not, please create a small demo project showing how to reproduce the error and make it available for download or post it on GitHub. |
It's very difficult to test (and also to create a demo Project) because error is aleatory. We don't understand the logic behind it. |
We also noticed versión 4.6 is much slower than the old 2.0 |
We have only had a handful of complaints about performance, and other than the known scalability limitations of having a limit of 10s of thousands of nodes, the rest all turned out to be misconfigured in some way. Fixing the configuration improved the performance in every other case. I have never compared the performance with 2.0, but there were several performance improvements made over the old 3.6 version, and it is definitely much faster. As for the error, it means that this node: <mvcSiteMapNode title="Soluciones Informáticas" controller="SolucionInformatica" action="Edit" preservedRouteParameters="id" visibility="SiteMapPathHelper,!*" /> has the "id" key in both the PreservedRouteParameters property and the RouteValues property of SiteMapNode when the SiteMap is loaded. Only one of these should be set. Clearly, your XML configuration is not setting the "id" of RouteValues, so you have a misconfiguration somewhere else. Based on your comment about performance and issue #236, my next guess is that you have turned caching off, which would explain both problems. <appSettings>
<add key="MvcSiteMapProvider_CacheDuration" value="0" />
</appSettings> Make sure you set the cache duration to something greater than 0. The default is 5 (minutes). <appSettings>
<add key="MvcSiteMapProvider_CacheDuration" value="5" />
</appSettings> If using external DI, the cache duration is set at the top of the DI module: TimeSpan absoluteCacheExpiration = TimeSpan.FromMinutes(5); Without caching, the performance will suffer. Also, you will get this exception because the SiteMap will load multiple times per request (once for each HTML helper) and the request caching of RouteValues will cause this collision the second time the "id" value is copied from the current ControllerContext into the node's RouteValues. There is a workaround for the problem, but it requires that you use external DI in order to apply it, and there is also a fix coming for it in the next minor version. However, unless your application is doing its own caching of the SiteMap data, there is no valid reason for turning off caching because it is an essential part of the design. Reloading the SiteMap can be done in 3 ways:
|
Thank you very much for all the advice and suggestions and for the prompt reply. Regards |
Returning to the theme of the slow, returned to the version 2.0.0.0 and is notable change in performance. Our sitemap is as follows (there are definite about 350 nodes and use dynamic nodes):
What is happening? thank you very much |
As far as I am aware, there is no documentation for the 2.0 version. I suggest you upgrade to 4.6.18 because at least I can support that version. We just need to find the problem with your configuration, and the performance issues will go away. I don't think there are any problems with the configuration of your nodes. However, as I have already stated, it sounds like you have set the "MvcSiteMapProvider_CacheDuration" setting to 0. This will definitely cause performance issues and would explain the other error you are getting. You should set it for at least 5 minutes. You might also have issues with the configuration you haven't posted. For example, improperly configured DynamicNodeProviders could lead to performance issues. Also, if you are using Security Trimming and have lots of code that runs in your controller constructors or inside of a custom AuthorizeAttribute you will have performance problems. Could you post your root web.config and your 2 dynamic node providers, StoreDetailsDynamicNodeProvider and ReporteEventosDynamicNodeProvider? |
Web.config: </system.web> <system.web> </system.web> <system.web> </system.web> <system.web> </system.web> <system.webServer> AppSettings: DynamicNodes
THANKS!!! |
Nothing unusual is jumping out of your configuration. Does performance improve by a large margin if you disable security trimming as a test? You might also try commenting groups of nodes in blocks to see if you can find the area that is causing the performance issue. The "divide and conquer" approach. You need to narrow this down to a particular node or a particular feature that is causing performance issues. Are you still receiving the original error? If so, does your project use [SiteMapPreserveRouteDataAttribute]? Do note that it is now obsolete and you should not be using it anymore. If this attribute is on your action method that corresponds to the node <mvcSiteMapNode title="Soluciones Informáticas" controller="SolucionInformatica" action="Edit" preservedRouteParameters="id" visibility="SiteMapPathHelper,!*" /> It could be causing the error. |
Were you able to resolve this issue? |
Closing as there has been no activity on this for several months. Feel free to reopen this issue if it is still unresolved. |
Hello.
In some cases, randomly displays the following error:
The node with key 'Home_Index_GET_Home__SolucionInformatica_index_GET_Activos__DataCenter_index_GET_Activos Informáticos__SolucionInformatica_Edit_GET_Soluciones Informáticas' and title 'Soluciones Informáticas' has 'id' configured in both RouteValues and PreservedRouteParameters, which is not allowed.
PreservedRouteParameters copies the route value from the current HTTP request which would overwrite your configured RouteValue in every case. Either remove 'id' from PreservedRouteParameters or as a configured RouteValue.
Alternatively, if you are configuring the node in XML and intend to use 'id' as a custom attribute, use the 'MvcSiteMapProvider_AttributesToIgnore' configuration setting to ensure 'id' is not automatically added to RouteValues. If using external DI, this setting is injected into the constructor of 'SiteMapXmlReservedAttributeNameProvider'.
The sitemap is configured as follows
If you do not use the 'PreservedRouteParameters' does not give the error, but does not the breadcrumb.
I am using version 4.6.18.0.
Thanks in advance
The text was updated successfully, but these errors were encountered: