Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange behaviour when loading razor view from custom VirtualPathProvider (ASHX Source)
    primarykey
    data
    text
    <p>I get some strange behaviour when I load data via my custom VirtualPathProvider. It might be important to mention, that I am trying to use this view as a layout.</p> <pre><code>public class MyVirtualPathProvider : VirtualPathProvider { public MyVirtualPathProvider() : base() { } public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { if ((virtualPath.StartsWith("/Path/") || virtualPath.StartsWith("~/Path/")) &amp;&amp; virtualPath.EndsWith(".cshtml")) { String name = virtualPath.Replace("/Path/", "").Replace(".cshtml", ""); Uri uri = new Uri("http://www.example.com/Handler.ashx?path=" + name); return new WebCacheDependency(uri.ToString()); } return base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart); } public override bool FileExists(string virtualPath) { if ((virtualPath.StartsWith("/Path/") || virtualPath.StartsWith("~/Path/")) &amp;&amp; virtualPath.EndsWith(".cshtml")) return true; return base.FileExists(virtualPath); } public override VirtualFile GetFile(string virtualPath) { if (virtualPath.StartsWith("/Path/") || virtualPath.StartsWith("~/Path/")) return new TemplateVirtualFile(virtualPath); return base.GetFile(virtualPath); } } </code></pre> <p>I also have implemented a custom (dummy) CacheDependency</p> <pre><code>public class WebCacheDependency : CacheDependency { public WebCacheDependency(String url) { this.SetUtcLastModified(DateTime.UtcNow); } } </code></pre> <p>Now there are two things that don't work. First, all loaded views are being cached and secondly, code inside the file (@Html.ActionLink ... etc.) does not work, It just gives an error "assembly missing".</p> <p>Has anyone an idea how to remedy those two problems?</p> <p>There's already a solution of the second problem (<a href="https://stackoverflow.com/questions/5159314/load-razor-view-from-db-but-viewbag-is-broken">link</a>) however I really don't get it how this problem can be solved inside the FileExists method.</p> <p>Thank you!</p> <p>Update: An image of the error message <img src="https://i.stack.imgur.com/iSnxM.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload