Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The path you're trying to go down is essentially <em>loading ASPX files from some other storage mechanism than the web server file system</em>. You've started to implement part of that, but you actually don't even need a custom HttpHandler to do this - ASP.NET has an existing mechanism for specifying other sources of the actual ASPX markup.</p> <p>It's called a <a href="http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx" rel="nofollow noreferrer"><strong>VirtualPathProvider</strong></a>, and it lets you swap out the default functionality for loading the files from disk with, say, loading them from SQL Server or wherever else makes sense. Then you can take advantage of all the built-in compiling and caching that ASP.NET uses on its own.</p> <p>The core of the functionality comes in the <a href="http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.getfile.aspx" rel="nofollow noreferrer">GetFile method</a> and the <a href="http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualfile.open.aspx" rel="nofollow noreferrer">VirtualFile's Open()</a>:</p> <pre><code>public override VirtualFile GetFile(string virtualPath) { //lookup ASPX markup return new MyVirtualFile(aspxMarkup); } //... public class MyVirtualFile : VirtualFile { private string markup; public MyVirtualFile(string markup) { this.markup = markup; } public override Stream Open() { return new StringReader(this.markup); } } </code></pre> <p>Note that today, using a custom VirtualPathProvider does require full trust. However, soon ASP.NET 4.0 will be available and it supports VPPs under medium trust.</p>
 

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