2016-07-15 84 views
2

我有一个类的自定义视图引擎的 从这个类派生的2个引擎ASP.NET MVC 4,为什么定义引擎没有找到一个视图

public class MyViewEngine : RazorViewEngine 
{ 
    public string UIFramework { get; set; } 

    public MyViewEngine(string uiFramework) 
    { 
     UIFramework = uiFramework; 
     this.ViewLocationFormats = new[] 
     { 
      string.Format("~/Views/{0}/{{1}}/{{0}}.cshtml", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/{{1}}/{{0}}.vbhtml", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/{{1}}/{{0}}.aspx", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/{{1}}/{{0}}.ascx", this.UIFramework ?? string.Empty), 
     }; 
      this.PartialViewLocationFormats = new[] 
     { 
      string.Format("~/Views/{0}/Shared/{{0}}.cshtml", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/Shared/{{0}}.vbhtml", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/Shared/{{0}}.aspx", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/Shared/{{0}}.ascx", this.UIFramework ?? string.Empty), 
     }; 
     this.MasterLocationFormats = new[] 
     { 
      string.Format("~/Views/{0}/Shared/{{0}}.cshtml", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/Shared/{{0}}.vbhtml", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/Shared/{{0}}.aspx", this.UIFramework ?? string.Empty), 
      string.Format("~/Views/{0}/Shared/{{0}}.ascx", this.UIFramework ?? string.Empty), 
     }; 

    } 


} 

这些2个引擎在Global.asax中

ViewEngines.Engines.Clear(); 
ViewEngines.Engines.Add(new MyViewEngine("First")); 
ViewEngines.Engines.Add(new MyViewEngine("Second")); 

查找“第二个视图引擎下”视图没有问题,但未找到“下”第一个视图。我可以看到,在ViewEngineResult搜索位置是正确的,发动机应该看到我的看法;而我的观点的名称是正确的太多,但仍然ViewEngineResult在查看property.Folders结构返回null是相同的,当然两个引擎

+0

尝试注释掉在Global.asax中的第二视图引擎和看到的结果 – Marusyk

回答

0

对不起,我的错误,这是与文件夹命名的问题。问题解决了

相关问题