This is a migrated thread and some comments may be shown as answers.

[Solved] Generate urls in menu using two different RouteMaps

6 Answers 29 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
jak
Top achievements
Rank 1
jak asked on 11 Feb 2011, 02:53 PM

Hi, Everybody!

For some reason in our site we need use "Default" MapRoute such as this:

routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

and in "SpecRoute" MapRoute such as this:

routes.MapRoute(
    "SpecRoute", // Route name
    "SPEC{sId}/{controller}/{action}/{id}", // URL with parameters
    new { controller = "Spec", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

The second Maproute as well as first maproute describes some controlles (1-st maproute: Home, Help, Goods, etc; 2-nd maproute: Spec, Details, Pays, etc.).

 I have next issue: I want to specify in Menu (sitemap or somewhere else) the routemap name to generate url with. For example:
for 1-st maproute url must look like this: http://server/Home, http://server/Help/Article/23, http://server/Goods/Item/50
for 2-ndmaproute url must look like this:  http://server/SPEC56/Details/, http://server/SPEC56/Details/Pays/267, etc.

Can anybody help me resolve or reject us impossible?

Thanks a lot for attention.

Yevhenii 

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Feb 2011, 02:57 PM
Hello jak,

The ASP.NET routing should work correctly when you specify the right controller and action. This means that the right URL should be returned and used by the menu component.

Of course I may not be getting your requirements. You can attach a simple running project which shows the case.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jak
Top achievements
Rank 1
answered on 11 Feb 2011, 03:05 PM

Hi, Atanas!

Well. I couldn't attach a simple project. 

Below is more describes of issue.

We have 2 MapRoutes ("Default" and "Spec"). When we navigating over "Default" MapRoute we don't have an issue. (Myabe becuase we don't show part of menu for "Spec" MapRoute). But when we go by URL like "http://server/SPEC56/Details/Pays/267" in menu we have got next URLs: http://server/SPEC56/Home instead http://server/Home, http://server/SPEC56/Help/Article/23 instead http://server/Help/Article/23, http://server/SPEC56/Goods/Item/50 instead http://server/Goods/Item/50, etc. 

(btw http://server/SPEC56/Goods/Item/50 work same as well as http://server/Goods/Item/50, but it look not very good)

Regards,

Yevhenii

0
Atanas Korchev
Telerik team
answered on 11 Feb 2011, 03:09 PM
Hi jak,

 Unfortunately I cannot understand the exact case without some code. Perhaps if you manage to create a sample project we would be able to help.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jak
Top achievements
Rank 1
answered on 11 Feb 2011, 03:44 PM

Hi, Atanas!

Please, find in attachment sample project.

Do next:

- run project

- go by links "About", "Register"  and look after URL in browser. (http://localhost:64418/Home/About, etc.)

- go by link "Special link" and check URL (http://localhost:64418/SPEC98/Special/Action/23)
- go again by link "About" and check URL (http://localhost:64418/SPEC98/Home/About). It looks a bit wrong. must be like "http://localhost:64418/Home/About"

Regards,

Yevhenii.

0
Accepted
Georgi Krustev
Telerik team
answered on 14 Feb 2011, 12:44 PM
Hello jak,

 
The aforementioned behavior is expected. Url.Action is used to build url for each MenuItem. Url.Action will use first matched Route, which will cause the issue. I will suggest you use this code snippet to overcome this problem:

...
        .BindTo("DefaultSiteMap", (item, siteMapNode) =>
        {
            item.Url(Url.RouteUrl("default",new { action = siteMapNode.ActionName, controller = siteMapNode.ControllerName }));
...


Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jak
Top achievements
Rank 1
answered on 14 Feb 2011, 01:04 PM

Thank you very much for your help

Regards, Yevhenii.

Tags
Menu
Asked by
jak
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
jak
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or