tags:

views:

46

answers:

3

for globalization reason I need to be able to do this:

 http://mysite/home
 http://mysite/Accueil

what I tried is to inherits home control in my Accueil class:

 Public Class AccueilController
     Inherits HomeController

 End Class

problem is, it's trying to go into the Accueil folder and look for index.aspx there

The view 'Index' or its master could not be found. The following locations were searched:
~/Views/Accueil/Index.aspx
~/Views/Accueil/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx

I would want it to use, so I don't have to duplicate code

~/Views/Home/Index.aspx

what would be the easiest way to do that?

A: 

The error message contains your answer. The view engine performs a progressive search for a matching view that moves through a set of configured folders. If you want a shared index view, put the Index.aspx file in ~/Views/Shared/, and that should do the trick.

If you need more flexible view locations, you could look into implementing a custom ViewLocator.

http://blogs.teamb.com/craigstuntz/2008/07/31/37827/

jrista
problem is, everything would be put there if I start doing that, everything from every controller this a big no no
Fredou
Why everything from every controller? If you just need a shared Index page, then stick it in shared. All the other views for other actions on your controllers can stay in their normal location.
jrista
+2  A: 

You are saying that for globalization reasons you need to have both urls render the same view. In this case I would suggest you to use the routing engine and map Accueil to home.

routes.MapRoute(
    "accueil",
    "Accueil/{action}",
    new 
    { 
        controller = "Home", 
        action = "Index"
    }
);
Darin Dimitrov