Provides a set of methods that enable a Web application to retrieve resources from a virtual file system.
See Also: VirtualPathProvider Members
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:
ASP.NET pages, master pages, user controls, and other objects.
Standard Web pages with extensions such as .htm and .jpg.
Any custom extension mapped to a System.Web.Compilation.BuildProvider instance.
Any named theme in the App_Theme folder.
You cannot store ASP.NET application folders or files that generate application-level assemblies in a virtual file system. This includes:
The Global.asax file.
Site map data files used by the System.Web.XmlSiteMapProvider.
Directories that contain application assemblies or that generate application assemblies: Bin, App_Code, App_GlobalResources, any App_LocalResources.
The application data folder, App_Data.
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.
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.