title: MVC 5 VirtualPathProvider not working as expected
body: <p>I've created the following virtual path provider to load views from a DB and when the view doesn't exist on disk, I am seeing my DB method in be called and return <code>true</code> for the FileExists method.  After that, no other methods are called and the page returns as a 404.  Views that are on disk are still rendering fine.  The DB call <code>GetByVirtualPath</code> just returns a views content.  I have validated that this object is hydrated with data.</p>
  
  <p><strong>VirtualPathProvider</strong></p>
  
  <pre><code>public class CMSVirtualPathProvider : VirtualPathProvider
  {
      public override bool FileExists(string virtualPath)
      {
          return base.FileExists(virtualPath) || MVCViewVersion.GetByVirtualPath(virtualPath) != null;
      }
  
      public override VirtualFile GetFile(string virtualPath)
      {
          if (base.FileExists(virtualPath))
          {
              return base.GetFile(virtualPath);
          }
          else
          {
              return new CMSVirtualFile(virtualPath, this);
          }
      }
  
      public override string GetFileHash(string virtualPath, IEnumerable virtualPathDependencies)
      {
          if (base.FileExists(virtualPath))
          {
              return base.GetFileHash(virtualPath, virtualPathDependencies);
          }
          else
          {
  #if DEBUG
              return null;
  #else
              return string.Format("{0}{1}", virtualPath, DateTime.UtcNow.ToString("dd HH"));
  #endif
          }
      }
  
      public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
      {
          if (!base.FileExists(virtualPath))
          {
              return null;
          }
          return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
      }
  }
  </code></pre>
  
  <p><strong>VirtualFile</strong>
  This class is never hit.</p>
  
  <pre><code>public class CMSVirtualFile : VirtualFile
  {
      private CMSVirtualPathProvider _ParentProvider;
  
      public CMSVirtualFile(string virtualPath, CMSVirtualPathProvider parentProvider)
          : base(virtualPath)
      {
          _ParentProvider = parentProvider;
      }
  
      public override System.IO.Stream Open()
      {
          string Content = string.Empty;
          MVCViewVersion Version = MVCViewVersion.GetByVirtualPath(this.VirtualPath);
  
          if (Version != null)
          {
              Content = Version.Content;
          }
  
          return new MemoryStream(ASCIIEncoding.Default.GetBytes(Content));
      }
  }
  </code></pre>
  
  <p>In the global.asax, I added the following link in the <code>Application_Start</code> method.</p>
  
  <pre><code>HostingEnvironment.RegisterVirtualPathProvider(new CMSVirtualPathProvider());
  </code></pre>
  
  <p>I assume something has changed as this code works on my previous implementation for MVC4.  I can't put my finger on what I am doing incorrectly.</p>