Skip to content
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

Bogus exception - id and preserved route parameters conflict #360

Closed
unklegwar opened this issue Sep 24, 2014 · 2 comments
Closed

Bogus exception - id and preserved route parameters conflict #360

unklegwar opened this issue Sep 24, 2014 · 2 comments

Comments

@unklegwar
Copy link

I have the following sitemap nodes (partial).

<mvcSiteMapNode title="Home" Description="Paris" controller="Home" action="Index"    >
    <mvcSiteMapNode title="Planning" controller="Planning" action="Index" securitycheckchildren="true" section="Main" >
        <mvcSiteMapNode title="Templates" breadcrumbtext="Template List" controller="PlanTemplate" action="Index" crudlevel="Read" >
            <mvcSiteMapNode title="Create Template: Add Template Information" controller="PlanTemplate" action="Create" preservedRouteParameters="id" />

I am receiving the following exception logged into our exception logger:

The node with key 'Home_Index_GET_Home__Planning_Index_GET_Planning__PlanTemplate_Index_GET_Templates__PlanTemplate_Create_GET_Create Template: Add Template Information' and title 'Create Template: Add Template Information' 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 PreservedRou

However, as you can see, the reported conflict between "id" and "preservedRouteParameters" does not exist.

@NightOwl888
Copy link
Collaborator

This has been fixed in v4.7, but has yet to be released. There are still many things to do before then, so I can't give an exact timeframe.

But if you are using external DI, you could use the cache decorator from here to work around the problem. It will request cache your SiteMap so it won't go out of scope between HTML helpers, which is what causes this.

The DI setup would be something along the lines of the following. Note that I haven't tested this, so you may need to tinker with it a bit.

            this.For(typeof(ICacheProvider<>)).Use(typeof(RuntimeCacheProvider<>));
            this.For<ICacheProvider<ISiteMap>>().Use<RequestCacheProvider<ISiteMap>>()
                .Ctor<ICacheProvider<ISiteMap>>("subCacheProvider").Is<RuntimeCacheProvider<ISiteMap>>();

What you need to know is that the RuntimeCacheProvider<T> type needs to be injected into the constructor of the RequestCacheProvider<T> type.

@NightOwl888
Copy link
Collaborator

Since this is essentially a duplicate of #310, I am closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants