When asked to return a view (ViewResult), the framework needs first to locate the view file (.cshtml).
The built-in conventions around locating view files are as follows:
- View files end with the cshtml extension.
- View filenames should be identical to the view names, minus the extension (for example, a view of Index will be stored in a file named Index.cshtml).
- View files are stored in a Views folder and inside a folder named after the controller they are returned from—for example, Views\Home.
- Global or shared views are stored in either the Views folder directly or inside a Shared folder inside of it—for example, Views\Shared.
Actually, this is controlled by the ViewLocationFormats collection of the RazorViewEngineOptions class (Razor is the only included view engine). This has the following entries, by default:
- /Views/{1}/{0}.cshtml ...