mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added custom razor engine to limit the view engine lookup to just c#
This commit is contained in:
parent
2db5878512
commit
bd6d71de46
51
Teknik/App_Start/CustomRazorViewEngine.cs
Normal file
51
Teknik/App_Start/CustomRazorViewEngine.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Teknik
|
||||
{
|
||||
public class CustomRazorViewEngine : RazorViewEngine
|
||||
{
|
||||
public CustomRazorViewEngine()
|
||||
{
|
||||
base.AreaViewLocationFormats = new string[]
|
||||
{
|
||||
"~/Areas/{2}/Views/{1}/{0}.cshtml",
|
||||
"~/Areas/{2}/Views/Shared/{0}.cshtml"
|
||||
};
|
||||
|
||||
base.AreaMasterLocationFormats = new string[]
|
||||
{
|
||||
"~/Areas/{2}/Views/{1}/{0}.cshtml",
|
||||
"~/Areas/{2}/Views/Shared/{0}.cshtml"
|
||||
};
|
||||
|
||||
base.AreaPartialViewLocationFormats = new string[]
|
||||
{
|
||||
"~/Areas/{2}/Views/{1}/{0}.cshtml",
|
||||
"~/Areas/{2}/Views/Shared/{0}.cshtml"
|
||||
};
|
||||
|
||||
base.ViewLocationFormats = new string[]
|
||||
{
|
||||
"~/Views/{1}/{0}.cshtml",
|
||||
"~/Views/Shared/{0}.cshtml"
|
||||
};
|
||||
|
||||
base.PartialViewLocationFormats = new string[]
|
||||
{
|
||||
"~/Views/{1}/{0}.cshtml",
|
||||
"~/Views/Shared/{0}.cshtml"
|
||||
};
|
||||
|
||||
base.MasterLocationFormats = new string[]
|
||||
{
|
||||
"~/Views/{1}/{0}.cshtml",
|
||||
"~/Views/Shared/{0}.cshtml"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,9 @@ namespace Teknik
|
||||
{
|
||||
protected void Application_Start()
|
||||
{
|
||||
ViewEngines.Engines.Clear();
|
||||
ViewEngines.Engines.Add(new CustomRazorViewEngine());
|
||||
|
||||
Database.SetInitializer(new MigrateDatabaseToLatestVersion<TeknikEntities, Migrations.Configuration>());
|
||||
|
||||
AreaRegistration.RegisterAllAreas();
|
||||
|
@ -137,6 +137,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Start\BundleConfig.cs" />
|
||||
<Compile Include="App_Start\CustomRazorViewEngine.cs" />
|
||||
<Compile Include="App_Start\FilterConfig.cs" />
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="Areas\About\AboutAreaRegistration.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user