November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I might be mistaken, but it seems like you're just casting a class to another class, which make no sense. You're missing the actual vpp object. What are you trying to achieve?
VirtualPathProviders are "chained" together (they have a property Previous that points to next in chain). System.Web.Hosting.HostingEnvironment.VirtualPathProvider will just point to the last in chain which might or might not be a VirtualPathUnifiedProvider (depending on which is registered last in your configuration).
If you are looking for getting a handle to a specific VirtualPathUnifiedProvider my suggestion is to use EPiServer.Web.Hosting.VirtualPathHandler.Instance.VirtualPathProviders where you can find the provider you are looking for.
Hello Johan, thank you for your fast answer, for my case, it is a VirtualPathNativeProvider, still it is null, even UnifiedFile casts are null. How am i suppose to do? customFile is null in this example.
ICollection<VirtualPathProvider> vpppp = EPiServer.Web.Hosting.VirtualPathHandler.Instance.VirtualPathProviders.Keys; UnifiedFile customFile = null; foreach (var x in vpppp) { VirtualPathNativeProvider x2 = x as VirtualPathNativeProvider; if (x2!=null && x2.ProviderName == "ImageBank") { VirtualFile vf = x2.GetFile(path); customFile = vf as UnifiedFile; } }
VirtualPathNativeProvider vpp = System.Web.Hosting.HostingEnvironment.VirtualPathProvider as VirtualPathNativeProvider
To get a file you should not need to call to a specific provider, since they are chained you should call the first and that one will send it to next in chain until a provider hanldes the file or null if no provider handles the file.
So if you call:
var file = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile(path)
what do you get back? Typically if no provider matches you get an instance of MapPathBasedVirtualFile.
What does your path look like? It should be a relative path like for example /Global/MyFile.jpg or ~/Global/MyFile.jpg
oh, i get it, but i do get a VirtualFile, but when i cast it to UnifiedFile it is null. Any Ide?
Strange behavior, the code below works though:
UnifiedDirectory directory = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetDirectory(originalsPath) as UnifiedDirectory;
Hi,
I have a fresh install of EPi 6 with Composer and in my code I am doing the following:
vpp = System.Web.Hosting.HostingEnvironment.VirtualPathProvider as VirtualPathUnifiedProvider;
if (vpp != null)
{
// do some stuff
}
However vpp is always null, is there a basic setting etc that I am blindly missing :-)
Thanks a in advance