Matan Shahar
Matan Shahar

Reputation: 3240

ASP.Net MVC3/4 multiple templates

There is any way to change the defualt views path in MVC3/4. i.e: The Url http://localhost:000/Home (the controller Home) will represent the view at Views/Style1/Home/Action.

Thanks ahead!

Upvotes: 2

Views: 147

Answers (2)

DennisG
DennisG

Reputation: 71

Ok, now that I understand the question better after the edit, I think this is what you're looking for:

You can change the ViewLocation in Application_Start().
The example below assumes use of the Razor View Engine.

ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine { ViewLocationFormats = new string[] { "~/Views/Style1/{1}/{0}.cshtml" } } );

Answer was partially derived and referenced from this post

Upvotes: 1

DennisG
DennisG

Reputation: 71

You should be able to set the Default route for your application to use a different base path. You can typically set the route in the Global.asax in the RegisterRoutes method.

Example:

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

Upvotes: 0

Related Questions