Skip to content

Example 02

Steffen Habermehl edited this page Mar 23, 2017 · 14 revisions

Configuration basics: Using the web.config

Note: This is only available in <= 2.2.5 releases
Backload. has a very rich set of configuration options. It can be entirely configured within the web.config file or alternatively a config file linked to the web.config. But, you do not have to set any option if you are happy with the defaults. In this example we show you how to prepare the web.config file, so Backload can be configured. In this example we want to change the root upload files path to "~/Uploads". Take a look how we utilize Visual Studio Intelligence and schema validation. Note: If you installed the Backload component by the NuGet Package Manager (PM> Install-Package Backload) the following steps are automatically done for you.

Prepare the web.config in two simple steps:

  1. Declare a new section group with a config section
  2. Add the section group and a config section to the configuration element
<configuration>
      <configSections>
        ...
        <!-- Declare the new section "backload" within <configSections> -->
        <section name="backload" type="Backload.Configuration.BackloadSection, Backload, Version=2, Culture=neutral, PublicKeyToken=02eaf42ab375d363" requirePermission="false" />
      </configSections>

      <!-- Add the new config section ("backload") to the <configuration> element -->
      <!-- Note: The xmlns:* and xsi:* attributes enable schema validation and Visual Studio Intelligence in the config file -->
      <backload storageContext="Filesystem" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <fileSystem filesRoot="~/Uploads" xmlns:name="urn:backload-schema" xsi:noNamespaceSchemaLocation="Backload\Config\Web.Backload.xsd">
        <fileSystem filesRoot="~/Uploads" />
      </backload>
      ...
</configuration>

Conclusion

This basic example shows how to prepare the web.config file for the Backload component. In this sample we set the root upload folder to "~/Uploads" (default: "~/files") and use the file system as storage context (default). Note: Don't forget to reference the schema file (Web.Backload.xsd) from your config file otherwise schema validation and Visual Studio Intelligence won't work. Make sure you have the appropriate write permissions. In the next example we show you how to use a separate config file in order to keep the web.config configuration clean.

 

You can’t perform that action at this time.