November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
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
/Hans
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
/Marten
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
/Hans
This loops throu all the VPP folders
public List<VirtualFile> GetAllFiles()
{
VirtualPathElement virtualPathSettings = EPiServerSection.Instance.VirtualPathSettings;
VirtualPathHandler instance = VirtualPathHandler.Instance;
instance.CustomFileSummary = virtualPathSettings.CustomFileSummary;
instance.InitializeProviders(virtualPathSettings.Providers);
instance.InitializeFilters(virtualPathSettings.Filters);
List<VirtualFile> allFiles = new List<VirtualFile>();
foreach (string key in instance.NameToVirtualPathMapping.Values)
{
DigFiles(instance.GetDirectory(key, false), allFiles);
}
return allFiles;
}
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: