Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



VirtualPathProvider: Store .ASPX and .HTM files for your application in xml file or database

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

Currently rated 2.8 by 4 people

  • Currently 2.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: General
Posted by crpietschmann on Friday, August 18, 2006 10:28 PM
Permalink | Comments (3) | Post RSSRSS comment feed

Related posts

Comments

Michal Talaga

Wednesday, August 23, 2006 2:42 AM

Michal Talaga

Hehe. I was just about to write something on this topic. A nice feature indeed.

Scott Isaacs

Thursday, August 31, 2006 6:18 AM

Scott Isaacs

That sounds very cool. Have you done any kind of benchmarking? I can't imagine that this would be faster than accessing files in the file system, but if the difference is minimal it could be very useful to store the files in a database in some situations.

Mathabo

Tuesday, October 03, 2006 5:42 PM

Mathabo

 Save the page as login.aspx
 A customer logs in to the web page of a company. He/she provides their username and password. The username and password is verified against a record in the customer table of the Company database. Create a customer table with information. There should also be username and password fields.
 If the customer is authenticated successfully (both username and password must match), it is next determined whether he/she is a gold customer or not (there is a y/n field in the table to show this).
 Save the name of the customer in a cookie on the client.
 All customers are now automatically directed to the store.aspx page.
 Otherwise he/she is sent to an error page called error.aspx where a meaningful error is displayed. this is what I should do Please help me find answers

Comments are closed

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann