jgauffin / griffin.mvccontrib

A contribution project for ASP.NET MVC3
http://blog.gauffin.org/tag/griffin-mvccontrib/
GNU Lesser General Public License v3.0
83 stars 40 forks source link

Routing issues with the plugin (portable areas) #22

Closed jspeshu closed 11 years ago

jspeshu commented 12 years ago

the URL's generated ( @item.CreateUri(Url) ) while using plugins seems to generate wrong links. to reproduce the problem click one of the plugin's urls, after that every link on the menu seems to fall apart and show wrong links, also additional actions don't seem to be resolved correctly

jgauffin commented 11 years ago

This has nothing to do with Griffin.MvcContrib. You should read up on how urls are generated for areas.

jspeshu commented 11 years ago

i thought the samples here( https://github.com/jgauffin/Samples/tree/master/Griffin.MvcContrib/Plugins/PluginSystemDemo.Mvc3 ) use Griffin.MvcContrib @ the background, for the menu items @ least. And I know how the urls get generated for areas. any ways the problem can be seen on the demo also may be that has some thing to do with Griffin.MvcContrib. if i'm not mistaken you have a plugin called messaging so when i type the url or click on the menu link messaging ( i.e. http://localhost/messaging). it works as expected. but after that all the menu links show or are liked i to an incorrect url e.g the the "About" menu is linked to (http://localhost/messaging/home/about/) which should be (http://localhost/home/about/) and if you have another plugin called someplugin it will also will be linked to (http://localhost/messaging) rather than being linked with (http://localhost/someplugin/what ever action) you are having currently.

jgauffin commented 11 years ago

yes. That's why I've configured the menu incorrectly.

Links pointing at the "default" area must be configured to use the default route.

jspeshu commented 11 years ago

I still didn't get it but if it's not a bug it's all right. And Thank you.

jgauffin commented 11 years ago

The problem is that MVC thinks that all links that have no specified route/area should use the current area. It's normally not a problem since all views are just just for the own area.

It's however a problem for the root controllers/views since they do not specify an area:

@Html.ActionLink("About", "About", "Home")

What we need to change that to:

@Html.ActionLink("About", "About", "Home", new { area = "Default" })

"Default" should be the name of the route specified in global.asax.

See here: http://stackoverflow.com/questions/2036305/how-to-specify-an-area-name-in-an-action-link

MsbowElite commented 11 years ago

Man, I created some others class librarys, so if I add 8 class library to main Project via references, only one work, the others Html.ActionLink do nothing, why? I changed the names of areas, and if I teste each one alone, all will do well.