LoginSignup
2
2

More than 5 years have passed since last update.

ASP.NET MVC でViewの検索先をシンプルに

Last updated at Posted at 2014-08-26

Razor 専用で良いし、VBとか使わない。
ついでに、Shareだと探すのが面倒なので、_Share で。
って人向け。

Global.asax.cs
        protected void Application_Start()
        {
            ...
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine {
                ViewLocationFormats = new[] {
                    "~/Views/{1}/{0}.cshtml",
                    "~/Views/_Shared/{0}.cshtml"
                },
                AreaViewLocationFormats = new[] {
                    "~/Areas/{2}/Views/{1}/{0}.cshtml",
                    "~/Areas/{2}/Views/_Shared/{0}.cshtml"
                }
            });
        }

わざわざ別クラスを作る必要はないよねってことで修正(2016.11.30)

2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2