With the VirtualPathProvider you can server pages from your website without the files actually existing on the disk. And this doesn’t use url rewriting. The VirtualPathProvider actually allows you create your own virtual file system within your application. You can store the pages of you site within an xml file, a database or any other method you would like. In my opinion this is one of the coolest new features in ASP.NET 2.0.
The virtual file system you create can store virtually any file that you would normally have on disk. These include:
- 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 BuildProvider instance.
- Any named theme in the App_Theme folder.
ASP.NET application folders or files that generate application-level assemblies cannot be stored in your new virtual file system. These include:
- The Global.asax file.
- Web.config files.
- Site map data files used by the XmlSiteMapProvider.
- Directories that contain application assemblies or that generate application assemblies: Bin, App_Code, App_GlobalResources, any App_LocalResources.
- The App_Data folder
Here is a zip file containing an example website that shows how to store static .htm files within an XML file. This example was derived from the code shown in the MSDN library.
Download Example: VirualPathProvider - Store static .htm pages in an XML file
- 01 Jul 2020
- 06 Apr 2020
- 11 Mar 2020
- 15 Feb 2020
- 02 Jan 2020
Recent on Build5Nines.com
Latest Cloud News: Azure Dev Guide eBook, xCloud, Cloud Shell + VNet and more! (August 11, 2020 – Build5Nines Weekly)11 Aug 2020
- 07 Aug 2020
Latest Cloud News: Azure Cloud Shell Tips, Azure Sphere, Microsoft acquire TikTok, NVidia acquire ARM, and more! (August 6, 2020 – Build5Nines Weekly)06 Aug 2020
- 01 Aug 2020
This site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. We also participates in affiliate programs with Udemy, and other sites. This site is compensated for referring traffic and business to these companies.