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!
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!
好的,现在我在编辑后更好地理解了这个问题,我认为这就是你要找的:
您可以在 Application_Start() 中更改 ViewLocation。
下面的示例假定使用 Razor 视图引擎。
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine { ViewLocationFormats = new string[] { "~/Views/Style1/{1}/{0}.cshtml" } } );
答案部分来自这篇文章并被引用
您应该能够为您的应用程序设置默认路由以使用不同的基本路径。您通常可以在 RegisterRoutes 方法的 Global.asax 中设置路由。
例子:
routes.MapRoute(
"Default", // Route name
"Style1/{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);