Using VirtualPathProvider and Server.MapPath??
Recently one of the engineers on my team (Amitkumar Sharma) got this issue reported by the customer where they had there own VirtualPathProvider to serve content from an alternate location rather then the default File System. The customer also wanted to use the Server.MapPath in conjunction but when they tried to return the actual physical path of the directory, it was returning the "Virtual Path"
The first time I heard of this from Amit, my thoughts were to tell him "Hey, that wont work!!!" and i was write, Look at it this way, when we are using a VirtualPathProvider the file could be located anywhere (literally anywhere), you could have the file located in a SQL Database or an alternative location (rather then the physical path) or even for example a zip file!!! so calling MapPath wont really work, would it?
But just to satisfy my curiosity i did take a peek at the source code (for MapPath) and indeed when we are using a VPP the path does get translated. I could talk a bit more about this provider since i have had more than a couple of issues to deal with but there really are enough resources on the web to tap into, so why reinvent the wheel. Once you get the hang of it, its relatively easy to use it. Having said that here are a list of resources that are quite useful if you are planning to use this provider.
VirtualPathProvider Class
http://msdn2.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx
How to use virtual path providers to dynamically load and compile content from virtual paths in ASP.NET 2.0
http://support.microsoft.com/kb/910441
Overriding ASP.NET combine behavior using a VirtualPathProvider
http://blogs.msdn.com/davidebb/archive/2005/11/27/overriding-asp-net-combine-behavior-using-a-virtualpathprovider.aspx
Virtualizing Access to Content: Serving Your Web Site from a ZIP File
http://msdn2.microsoft.com/en-us/library/aa479502.aspx