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

[Question] Integration with RouteLocalization library? #357

Closed
JobaDiniz opened this issue Sep 11, 2014 · 4 comments
Closed

[Question] Integration with RouteLocalization library? #357

JobaDiniz opened this issue Sep 11, 2014 · 4 comments

Comments

@JobaDiniz
Copy link

I'm using this library: https://github.com/Dresel/RouteLocalization
Looks like MvcSiteMapProvider isn't working when I add that library. Notice that the library created LocalizationRoute which inherits from Route.

Is that an issue?

@NightOwl888
Copy link
Collaborator

MvcSiteMapProvider is designed to work with the System.Web.Routing framework, in particular to work with subclasses of Route and RouteBase, as long as both the GetRouteData and GetVirtualPath methods are set up to be exact mirror images of each other for the incoming and outgoing route. The incoming route is to match a resource (typically a controller action) and the outgoing route is to generate a URL. MvcSiteMapProvider uses both.

I took a look at the source in that library and I don't see any reason why it wouldn't work with MvcSiteMapProvider, but do keep in mind that all route parameters of the request (whether you or a 3rd party supplies them) must be configured to match, either by supplying 1 node per route combination or using preservedRouteParameters to force a particular parameter to match regardless of its value.

I suggest you set a breakpoint in your controller action and analyze the following 2 things (and perhaps the rest of the RouteData information) carefully to ensure there is nothing about the route that is unusual (extra route parameters, route information being tucked into a nested route key that is NOT named "MS_DirectRouteMatches", etc.)

?this.ControllerContext.RouteData.Values.Keys
?this.ControllerContext.RouteData.Values.Values

It would also be helpful to know how MvcSiteMapProvider is not working. Is it failing to show up at all, or are the URLs incorrect?

@JobaDiniz
Copy link
Author

"It would also be helpful to know how MvcSiteMapProvider is not working. Is it failing to show up at all, or are the URLs incorrect?"

The menu is showing, but the links are not right.
When I type http://localhost:39231/en-US/Datasource, all links in menu become: http://localhost:39231/en-US/Datasource#
Same if I type http://localhost:39231/pt-BR/fonte-de-dados

@JobaDiniz
Copy link
Author

Turns out it is RouteLocalization issue. There are some string comparasions issues: Dresel/RouteLocalization#19 (comment)

@NightOwl888
Copy link
Collaborator

Okay, good to know.

FYI - when the URL resolves as "#", it means that MVC couldn't resolve the URL with any of the configured routes. You can always use the code here inside of a controller to determine if the URL will resolve within MVC, and if not the problem is most definitely not with MvcSiteMapProvider, but with the route configuration.

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

No branches or pull requests

2 participants