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

Visibility & resourceKey question #305

Closed
lgoudriaan opened this issue Apr 8, 2014 · 4 comments
Closed

Visibility & resourceKey question #305

lgoudriaan opened this issue Apr 8, 2014 · 4 comments

Comments

@lgoudriaan
Copy link

How can I set visibility on a MvcSiteMapNodeAttribute?

And how can I localize using the resourceKey?

@NightOwl888
Copy link
Collaborator

Visibility is a custom attribute. You can set it on MvcSiteMapNodeAttribute using the Attributes property. Note that due to limitations of .NET attributes, it is set using a JSON string (see #266).

[MvcSiteMapNode(Title = "Some Page", Attributes = @"{ ""visibility"": ""MenuHelper,!*"" }")]

As for implicit localization, see #228. It is currently only possible if using an external DI container and implementing ISiteMapCacheKeyGenerator. I wouldn't recommend using implicit localization because of its uncertain future - it will either be dropped entirely or redesigned in the next version.

@lgoudriaan
Copy link
Author

Thanks for the fast response!
Now I get this error when adding the attributes property:

The node with key 'debtors' may not add a route value with the key 'visibility' and value 'MenuHelper,!*' to the RouteValues dictionary because the key is a reserved name. Reserved names are keys that are meant for use internally by MvcSiteMapProvider rather than a dictionary value.

ps. I use VB

@NightOwl888
Copy link
Collaborator

This is due to a bug in the RouteValues collection - it was not passing the throwIfReservedKey argument when adding the Attributes, which was causing the error. It has now been fixed in v4.6.3, which will be available on NuGet in a few minutes.

@lgoudriaan
Copy link
Author

Thanks again!

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