DocumentUltimateWebConfigurationCacheLocation Property

Gets or sets the location to store cached documents. The default value is "~/App_Data/DocumentCache".

This property can be set to:

  • A plain string which contains a physical/virtual path
    (e.g. "c:\SomeFolder", "/SomeFolder", "~/SomeFolder").

    This is parsed as PhysicalLocation.

    Note that virtual paths can only be resolved in a web application
    and on Linux paths starting with "/" are physical paths and not virtual paths.

  • A Location instance created with one of the builtin location providers
    (e.g. PhysicalLocation, AzureBlobLocation, AmazonS3Location, ArchiveLocation).

    You can also override Location base class to implement your custom location provider.

  • A provider string which defines a specific location provider
    (e.g. "Type=Physical; Path=c:\SomeFolder").

Definition

Namespace: GleamTech.DocumentUltimate.AspNet
Assembly: GleamTech.DocumentUltimate (in GleamTech.DocumentUltimate.dll) Version: 7.2.0
C#
public Location CacheLocation { get; set; }

Property Value

Location

Example

Setting global cache location in code:

C#
//Setting a physical path string:
//See below for other path string examples.
DocumentUltimateWebConfiguration.Current.CacheLocation = @"c:\SomeFolder\DocumentCache";

//Setting a virtual path string:
//See below for other path string examples.
DocumentUltimateWebConfiguration.Current.CacheLocation = "~/App_Data/DocumentCache";

//Setting a location provider instance:
//See below for other location provider examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
DocumentUltimateWebConfiguration.Current.CacheLocation = new PhysicalLocation
{
    Path = @"c:\SomeFolder\DocumentCache"
};

//Setting a provider string:
//See below for other provider string examples (UNC Path, AmazonS3, AzureBlob, Database etc.).
DocumentUltimateWebConfiguration.Current.CacheLocation = @"Type=Physical; Path=c:\SomeFolder\DocumentCache";

Setting global cache location in appsettings.json file:

JSON
{
  //Setting a path string:
  //See below for other path string examples.
  "DocumentUltimateWeb:CacheLocation": "c:\\SomeFolder\\DocumentCache",

  //Setting a provider string:
  //See below for other provider string examples.
  "DocumentUltimateWeb:CacheLocation": "Type=Physical; Path=c:\\SomeFolder\\DocumentCache"
}

Setting global cache location in <appSettings> tag of Web.config file:

XML
<appSettings>
  <!-- 
  Setting a physical path string:
  See below for other path string examples.
  -->
  <add key="DocumentUltimateWeb:CacheLocation" value="c:\SomeFolder\DocumentCache"/>

  <!-- 
  Setting a virtual path string:
  See below for other path string examples.
  -->
  <add key="DocumentUltimateWeb:CacheLocation" value="~/App_Data/DocumentCache"/>

  <!-- 
  Setting a provider string:
  See below for other provider string examples.
  -->
  <add key="DocumentUltimateWeb:CacheLocation" value="Type=Physical; Path=c:\SomeFolder\DocumentCache"/>
</appSettings>

  Notes to Callers

Below are the examples for setting a Location parameter/property.

Setting a plain string:

C#
Location location;

//Setting a physical path string:
//This is parsed as a PhysicalLocation instance.
location = @"c:\SomeFolder";

//Setting a virtual path string:
//This is parsed as a PhysicalLocation instance and virtual path is resolved on access.
//Note that virtual paths can only be resolved in a web application
//and on Linux paths starting with "/" are physical paths and not virtual paths.
location = "~/SomeFolder";

Setting a physical location:

C#
Location location;

//Setting a physical location via a PhysicalLocation instance:
location = new PhysicalLocation
{
    //Path can also be virtual path string like "~/App_Data/SomeFolder" in a web application.
    Path = @"c:\SomeFolder"
};

//Setting a physical location via a provider string (same as above):
location = @"Type=Physical; Path=c:\SomeFolder";

//---------------------------------------

//Setting a physical location via a PhysicalLocation instance, to connect as a specific user:
//UserName can be specified as "Domain\User", "User@Domain" (UPN format), "Machine\User", "User" (local user).
location = new PhysicalLocation
{
    Path = @"\\server\share", //a UNC path or a local path
    UserName = "USERNAME",
    Password = "PASSWORD"
};

//Setting a physical location via a provider string, to connect as a specific user (same as above):
//In a provider string, if a value contains semi-colon character, that value should be enclosed
//in single quotes (eg. Password='PASS;WORD') or double quotes (eg. Password="PASS;WORD").
location = @"Path=\\server\share; User Name=USERNAME; Password=PASSWORD";

//---------------------------------------

//Setting a physical location via a PhysicalLocation instance, to connect as the authenticated user:
//If Windows Authentication is used in IIS for this site, location can be specified like this
//to connect as the already authenticated user: 
location = new PhysicalLocation
{
    Path = @"\\server\share", //a UNC path or a local path
    AuthenticatedUser = AuthenticatedUser.Windows
};

//Setting a physical location via a provider string, to connect as the authenticated user:
location = @"Path=\\server\share; Authenticated User=Windows";

Setting an Azure Blob location:

C#
Location location;

//Setting an Azure Blob location via an AzureBlobLocation instance:
location = new AzureBlobLocation
{
    //Leave Path empty to connect to the root of the container. 
    //For connecting to subfolders, Path should be specified as a relative path (eg. "some/folder")
    //Path = "some/folder",

    //Get these values from your Azure Portal (Storage Account -> Access Keys -> Connection String)
    Container = "CONTAINER",
    AccountName = "XXX",
    AccountKey = "XXX"
};

//Setting an Azure Blob location via a provider string (same as above):
//In a provider string, if a value contains semi-colon character, that value should be enclosed
//in single quotes (eg. Password='PASS;WORD') or double quotes (eg. Password="PASS;WORD").
location = "Type=AzureBlob; Container=CONTAINER; Account Name=XXX; Account Key=XXX";

Setting an Amazon S3 location:

C#
Location location;

//Setting an Amazon S3 location via an AmazonS3Location instance:
location = new AmazonS3Location
{
    //Leave Path empty to connect to the root of the bucket. 
    //For connecting to subfolders, Path should be specified as a relative path (eg. "some/folder")
    //Path = "some/folder",

    BucketName = "BUCKET",
    Region = "eu-central-1",
    AccessKeyId = "XXX",
    SecretAccessKey = "XXX",
};

//Setting an Amazon S3 location via a provider string (same as above):
//In a provider string, if a value contains semi-colon character, that value should be enclosed
//in single quotes (eg. Password='PASS;WORD') or double quotes (eg. Password="PASS;WORD").
location = "Type=AmazonS3; Bucket Name=BUCKET; Region=eu-central-1; Access Key Id=XXX; Secret Access Key=XXX";

See Also