Class VirtualPathMappedProvider
A virtual path provider for mapping specific virtual paths to other locations. The mappings are configured in web.config.
Inheritance
Namespace: EPiServer.Web.Hosting
Assembly: EPiServer.Framework.dll
Version: 8.11.0Syntax
public class VirtualPathMappedProvider : VirtualPathProvider
Constructors
VirtualPathMappedProvider(String, NameValueCollection)
Default constructor.
Declaration
public VirtualPathMappedProvider(string name, NameValueCollection configParameters)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the provider |
System.Collections.Specialized.NameValueCollection | configParameters | The config parameters for the provider |
Properties
PathMappings
Adds Virtualmappings to dictionary
Declaration
public Dictionary<string, string> PathMappings { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> |
Remarks
For testing purposes can it be set, otherwise during runtime it is read from config file.
Dictionary implements StringComparer.OrdinalIgnoreCase
Provider
Returns the VirtualPathProvider to use.
Declaration
public VirtualPathProvider Provider { get; set; }
Property Value
Type | Description |
---|---|
System.Web.Hosting.VirtualPathProvider |
Remarks
By default it returns GenericHostingEnvironment.Instance.VirtualPathProvider. For testing purpose it can be assigned.
WebConfigHash
Gets hashcode for web.config Creates hashcode from FileInfo object. (webConfig path, CreationTime, LastWriteTime, Length)
Declaration
public string WebConfigHash { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
Can be set for test puropses.
Methods
DirectoryExists(String)
Checks if this VPP has knowlegde in existance of directory under virtualPath. If not passes the query to the next provider in chain (if any).
Declaration
public override bool DirectoryExists(string virtualDir)
Parameters
Type | Name | Description |
---|---|---|
System.String | virtualDir | The virtual path to check existence for |
Returns
Type | Description |
---|---|
System.Boolean | true if the directory exists in the virtual file system; otherwise, false. |
FileExists(String)
Checks if this VPP has knowlegde in existance of file under virtualPath. If not passes the query to the next provider in chain (if any).
Declaration
public override bool FileExists(string virtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | virtualPath |
Returns
Type | Description |
---|---|
System.Boolean |
GetCacheDependency(String, IEnumerable, DateTime)
If the path is mapped it will add a cachedependency to the mapped file.
Declaration
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
Parameters
Type | Name | Description |
---|---|---|
System.String | virtualPath | |
System.Collections.IEnumerable | virtualPathDependencies | |
System.DateTime | utcStart |
Returns
Type | Description |
---|---|
System.Web.Caching.CacheDependency |
GetDirectory(String)
Gets the virtualPath directory. If it doesn't exists under this providers responibillity it transfers the request to the next provider in chain.
Declaration
public override VirtualDirectory GetDirectory(string virtualDir)
Parameters
Type | Name | Description |
---|---|---|
System.String | virtualDir | The path to the virtual directory. |
Returns
Type | Description |
---|---|
System.Web.Hosting.VirtualDirectory | VirtualDirectory or null |
GetFile(String)
Gets the virtualPath file. If it doesn't exists under this providers responibillity it transfers the request to the next provider in chain.
Declaration
public override VirtualFile GetFile(string virtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | virtualPath |
Returns
Type | Description |
---|---|
System.Web.Hosting.VirtualFile | VirtualFile or null. |
GetFileHash(String, IEnumerable)
Adds web.config hash to virtualPath
Declaration
public override string GetFileHash(string virtualPath, IEnumerable virtualPathDependencies)
Parameters
Type | Name | Description |
---|---|---|
System.String | virtualPath | Path to file |
System.Collections.IEnumerable | virtualPathDependencies | Path to dependencies to virtualPath file |
Returns
Type | Description |
---|---|
System.String | string |
Remarks
Because we have configuration in web.config for VirtualPathMappings we need to know when web.config has changed and reload mappings. By default virtualprovider sets only dependencies to file and controls on pages we have mapping to, it doesnt recognize web.config as a dependecy Thats why we adding HashCode for webconfig with return
Examples
Web.config.