private void RegisterCustomViewFolders() //================================================================================================================ // Register custom view folders // // Developer Notes // When a view name is referenced in code, MVC will search for the view in both the "Views" and the // "Views/Shared" folders. If you create other subfolders under the "Views" folder MVC does not know about // them. This does not leave much room for proper organization as the "Shared" folder should really only // contain views that are shared across the entire site. To solve this problem I use a product called // Enhanced View Locator which is used to register other view folders with MVC. //================================================================================================================ { // Give priority to the standard view locations so we don't always search our // custom folders first when searching for a view. EnhancedViewLocator.EnableStandardRazorCSLocations(); // Add custom view folders EnhancedViewLocator.AddFolder("Views/APIDemos"); EnhancedViewLocator.AddFolder("Views/CardShuffler"); EnhancedViewLocator.AddFolder("Views/PokerRoom"); EnhancedViewLocator.AddFolder("Views/Randomness"); EnhancedViewLocator.AddFolder("Views/Shared/Dialogs"); EnhancedViewLocator.AddFolder("Views/Shared/Dialogs/PageErrors"); EnhancedViewLocator.AddFolder("Views/Shared/Dialogs/UserPrompt"); EnhancedViewLocator.AddFolder("Views/Shared/Dialogs/UserQuestion"); EnhancedViewLocator.AddFolder("Views/Shared/Forms"); EnhancedViewLocator.AddFolder("Views/Shared/MiniMenu"); EnhancedViewLocator.AddFolder("Views/Shared/Shuffler"); // Install a custom view engine to manage the lookups. EnhancedViewLocator.Install(ControllerBuilder.Current); }
private static void RegisterCustomViewLocations() { // We can optionally enable the standard Razor view CS (or VB) locations // so we don't always search our extra / custom areas first when // searching for a view. EnhancedViewLocator.EnableStandardRazorCSLocations(); EnhancedViewLocator.AddFolder("views/account/employee"); EnhancedViewLocator.AddFolder("views/account/representative"); EnhancedViewLocator.AddFolder("views/shared/address"); EnhancedViewLocator.AddFolder("views/shared/paymentmethod"); EnhancedViewLocator.AddFolder("views/shared/order"); EnhancedViewLocator.AddFolder("views/shared/review"); EnhancedViewLocator.AddFolder("views/shared/shoppingcart"); EnhancedViewLocator.AddFolder("views/shared/layouts"); EnhancedViewLocator.AddFolder("views/shared/profile"); EnhancedViewLocator.AddFolder("views/shared/profile/contact"); EnhancedViewLocator.AddFolder("views/shared/profile/contact/email"); EnhancedViewLocator.AddFolder("views/shared/profile/contact/phone"); EnhancedViewLocator.AddFolder("views/shared/profile/personal"); EnhancedViewLocator.AddFolder("views/shared/profile/food"); EnhancedViewLocator.AddFolder("views/shared/settings"); EnhancedViewLocator.AddFolder("views/shared/item"); EnhancedViewLocator.AddFolder("views/shared/product"); // Finally, have the locator install a custom view engine to manage the lookups. EnhancedViewLocator.Install(ControllerBuilder.Current); }
private static void RegisterCustomViewLocations() { // We can optionally enable the standard Razor view CS (or VB) locations // so we don't always search our extra / custom areas first when // searching for a view. EnhancedViewLocator.EnableStandardRazorCSLocations(); // Next, add two extra locations to store / arrange our views. // 1. in the templates folder under the standard shared view folder. EnhancedViewLocator.AddFolder("views/shared/templates"); // 2. in the navigation folder under the standard shared view folder. EnhancedViewLocator.AddFolder("views/shared/navigation"); // Finally, have the locator install a custom view engine to manage the lookups. EnhancedViewLocator.Install(ControllerBuilder.Current); }