Code Samples on Virtual Path Providers | Tech Note on Virtual Path Providers

An Introduction to Virtual Path Providers in EPiServer

Using Virtual Path Providers is one way to access server pages and files in ASP.NET 2.0 web applications. VPP is the mechanism that ASP.NET uses to load and compile content.

For a brief introduction, see ASP.NET Compilation Overview at

The new file handling in EPiServer uses this technique to provide files from an underlying virtual file system. ASP.NET 2.0 can have a chain of providers which each in turn has the option to serve a file from a virtual path to the requesting client.

The API is only built to serve files, not to, for example, create them. The new EPiServer API for handling virtual files extends the core API and provides the functionality formerly residing in UnifiedFileSystem.

The extended API is located in the namespace EPiServer.Web.Hosting in relation to the core classes from System.Web.Hosting.

In older versions of EPiServer the UnifiedFileSystem was an abstraction class and the entry point for available file system implementations. In the new model the entry point is served by the ASP.NET 2.0 API using the System.Web.Hosting namespace.

Example in old versions of EPiServer:

UnifiedFile file = UnifiedFileSystem.GetFile(path);

When the edit and admin UI controls request files they work with the interfaces to detect supporting provider implementations.

The new call in EPiServer CMS would be (For providers required to deliver files/directories with UI Support):

UnifiedFile uf = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile(path) as UnifiedFile;

For other custom controls who want to request files from ASP.NET and donít need to work with the EPiServer extension (For providers without UI Support):

VirtualFile vf = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile(path);