VirtualPathProviderViewEngine

下载源码:http://download.csdn.net/detail/kingcruel/8515165


MvcApplication1项目使用的是:Razor      ->      _Layout.cshtml      ->      Core.Framework.ThemeRazorViewEngine

Global.asax.cs代码

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

    //将默认视图引擎替换为ThemeRazorViewEngine引擎
    ViewEngines.Engines.Clear();
    ViewEngines.Engines.Add(new ThemeRazorViewEngine());
}

MvcApplication2项目使用的是:ASPX      ->      Site.Master      ->      Core.Framework.ThemeWebFormViewEngine

Global.asax.cs代码

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

    //将默认视图引擎替换为ThemeRazorViewEngine引擎
    ViewEngines.Engines.Clear();
    ViewEngines.Engines.Add(new ThemeWebFormViewEngine());
}


升级


Core.Framework.ThemeRazorViewEngine


类中做了如下修改:


public ThemeRazorViewEngine()
{
    AreaViewLocationFormats = new[]
    {
        //主题
        "~/Areas/{2}/Views/{1}/{0}.cshtml",
        "~/Areas/{2}/Views/Shared/{0}.cshtml",
    };

    AreaMasterLocationFormats = new[]
    {
        //主题
        "~/Areas/{2}/Views/Shared/{0}.cshtml",
    };

    AreaPartialViewLocationFormats = new[]
    {
        //主题
       "~/Areas/{2}/Views/{1}/{0}.cshtml", 
       "~/Areas/{2}/Views/Shared/{0}.cshtml", 
    };

    ViewLocationFormats = new[]
    {
        //主题
        "~/Views/{1}/{0}.cshtml", 
        "~/Views/Shared/{0}.cshtml",
    };

    MasterLocationFormats = new[]
    {
        //主题
        "~/Views/Shared/{0}.cshtml", 
    };

    PartialViewLocationFormats = new[]
    {
       //主题
       "~/Views/{1}/{0}.cshtml", 
       "~/Views/Shared/{0}.cshtml", 
    };

}


Core.Framework.ThemeWebFormViewEngine


类中做了如下修改:


public ThemeWebFormViewEngine()
{
    AreaViewLocationFormats = new[]
    {
        "~/Areas/{2}/Views/{1}/{0}.aspx",
        "~/Areas/{2}/Views/{1}/{0}.ascx",
        "~/Areas/{2}/Views/Shared/{0}.aspx",
        "~/Areas/{2}/Views/Shared/{0}.ascx",
    };

    AreaMasterLocationFormats = new[]
    {
        "~/Areas/{2}/Views/{1}/{0}.master",
        "~/Areas/{2}/Views/Shared/{0}.master",
    };


    MasterLocationFormats = new[]
    {
        "~/Views/{1}/{0}.master",
        "~/Views/Shared/{0}.master"
    };

   
    ViewLocationFormats = new[]
    {
        "~/Views/{1}/{0}.aspx",
        "~/Views/{1}/{0}.ascx",
        "~/Views/Shared/{0}.aspx",
        "~/Views/Shared/{0}.ascx"
    };

    PartialViewLocationFormats = ViewLocationFormats;
    AreaPartialViewLocationFormats = AreaViewLocationFormats;
}


你可能感兴趣的:(VirtualPathProviderViewEngine)