Try our conversational search powered by Generative AI!

List of all Virtual Page Providers


What would be the easiest way of programmatically obtaining a list of all available VPP's and its properties in web.config?

In effect, this is the pseudo code of what I would like:

string s = "";
foreach(VirtualPageProvider vpp in myVirtualPageProviderCollection) { s += string.Format("VirtualName: {0}, VirtualPath: {1}", vpp.VirtualName, vpp.VirtualPath); }
Oct 22, 2008 13:43

Something like this 

using System.Collections.Generic;
using System.Configuration;
using System.Web.Hosting;
using EPiServer.Web.Hosting;

VirtualPathHandler virtualPathHandler = VirtualPathHandler.Instance;
foreach (KeyValuePair<VirtualPathProvider, ProviderSettings> keyValuePair in virtualPathHandler.VirtualPathProviders)
    Response.Write("<p>" + String.Format("Name: {0}, VirtualName: {1}, VirtualPath: {2}, Type: {3}", (keyValuePair.Value as ProviderSettings).Name, (keyValuePair.Value as ProviderSettings).Parameters["virtualName"], (keyValuePair.Value as ProviderSettings).Parameters["virtualPath"], (keyValuePair.Key as VirtualPathProvider).GetType().FullName) + "</p>");

Hope it helps


Oct 23, 2008 10:02

Thanks for your reply, but I get an error with that code. EPiServer.Web.Hosting.VirtualPathHandler does not seem to contain a definition for "VirtualPathProviders" - as in "virtualPathHandler.VirtualPathProviders" in the foreach above. I'm using CMS R1 SP3. Maybe this works with R2?

By the way, also thanks for posting the code without using the code snippet function in this editor, unlike me... your way makes the code more readable


Oct 23, 2008 12:02

Ok, made it with R2.

Maybe you can use:
foreach(KeyValuePair<String, String> in VirtualPathHandler.Instance.VirtualPathToNameMapping)

See what you get and then maybe use VirtualPathHandler.GetProvider(String providerName)

Havent tried though


Oct 23, 2008 12:44

This loops throu all the VPP folders 

public List<VirtualFile> GetAllFiles()
            VirtualPathElement virtualPathSettings = EPiServerSection.Instance.VirtualPathSettings;
            VirtualPathHandler instance = VirtualPathHandler.Instance;
            instance.CustomFileSummary = virtualPathSettings.CustomFileSummary;
            List<VirtualFile> allFiles = new List<VirtualFile>();

            foreach (string key in instance.NameToVirtualPathMapping.Values)
                DigFiles(instance.GetDirectory(key, false), allFiles);
            return allFiles;

Oct 23, 2008 23:21
Thanks a lot, will try this!
Oct 23, 2008 23:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.