c# - How to put .Mobile views in another folder with MVC4? -


In MVC 4, you can simply add. Mobile for any visual and mobile devices automatically the same controller. Is there any way to store it? Mobile files in a separate folder? I really want to store desktop files in a "region" and another "area". Does anyone know something like this? It can be easily accomplished by adding and adding a custom implementation of RazorViewEngine and custom mapping in ViewLocationFormats of it.

It is important to remember to add custom mapping to the beginning of the ViewLocationFormats array, as they are more specific than existing mapping.

  Namespace MobileViewsInMobileFolder.Utility {PUBLIC SQUARE MyCustomViewEngine:. RazorViewEngine {public MyCustomViewEngine () {list & lt; String & gt; Existing Visual Viewformats = Vertical Formatting .Oolist (); // folder structure: view \ home \ desktop and view \ home \ mobile currentViewLocationFormats.Insert (0, "~ / scene / {1} / desktop / {0} .cshtml"); Existing Visual Viewformat.Inset (0, "~ / scene / {1} / mobile / {0} .cshtml"); // Folder structure: view \ desktop \ home and \ mobile \ homeVersionViewLocationFormats.Insert view (0, "~ / scene / desktop / {1} / {0} .cshtml"); Current Visual Viewformat.Inset (0, "~ / visual / mobile / {1} / {0} .cshtml"); ViewLocationFormats = Existing viewpoint formats.ORRA (); }}}   

and then be sure to add a custom view engine to Application_Start

  ViewEngines.Engines.Clear (); ViewEngines.Engines.Add (New MyCustomViewEngine ());    

Comments