System.Web.Hosting.VirtualPathProvider Class

Provides a set of methods that enable a Web application to retrieve resources from a virtual file system.

See Also: VirtualPathProvider Members

Syntax

public abstract class VirtualPathProvider : MarshalByRefObject

Remarks

The System.Web.Hosting.VirtualPathProvider class provides a set of methods for implementing a virtual file system for a Web application. In a virtual file system, the files and directories are managed by a data store other than the file system provided by the server's operating system. For example, you can use a virtual file system to store content in a SQL Server database.

You can store any file that is processed on request in a virtual file system. This includes:

You cannot store ASP.NET application folders or files that generate application-level assemblies in a virtual file system. This includes:

Note:

If a Web site is precompiled for deployment, content provided by a System.Web.Hosting.VirtualPathProvider instance is not compiled, and no System.Web.Hosting.VirtualPathProvider instances are used by the precompiled site.

Registering a VirtualPathProvider

A custom System.Web.Hosting.VirtualPathProvider instance should be registered with the ASP.NET compilation system by using the HostingEnvironment.RegisterVirtualPathProvider(VirtualPathProvider) method before any page parsing or compilation is performed by the Web application.

Typically, a System.Web.Hosting.VirtualPathProvider instance is registered in an AppInitialize method defined in the App_Code directory, or during the Application_Start event in the Global.asax file. For an example of registering a System.Web.Hosting.VirtualPathProvider instance in an AppInitialize method, see the Example section.

You can register a System.Web.Hosting.VirtualPathProvider instance during other events, but pages compiled and cached before the System.Web.Hosting.VirtualPathProvider instance is registered will not be invalidated, even if the new System.Web.Hosting.VirtualPathProvider instance would now provide the source for the previously compiled page.

Requirements

Namespace: System.Web.Hosting
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0