Skip to content
blackcity edited this page Jul 2, 2013 · 2 revisions

###Configuration basics: Using an external config file 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 configure the Backload. component in a separate config file, in order to keep the web.config clean. This example does the same as the previous Example 02: We change the root upload files path to "~/Uploads", but now in a separate config file (web.FileUpload.config). Take a look how we utilize Visual Studio Intelligence and schema validation.

####How to include an external config file:

  1. Prepare the web.config file as in Example 02
  2. Add a configSource attribute to the fileUpload section with an appropriate file path that points to the external config file (e.g. Web.FileUpload.config). Omit any other settings.
<configuration>
  <configSections>
    ...
    <!--
      You can place the entire configuration in the web.config. Alternatively you can seperate the configuration
      in its own config file as shown below. Just copy this sectionGroup declaration and the implementation below
      with the appropriate configSource parameter into your web.config file.
    -->
    <sectionGroup name="fileUploadGroup">
      <section name="fileUpload" 
               type="Backload.Configuration.FileUploadSection, Backload, Version=1.7, Culture=neutral, PublicKeyToken=02eaf42ab375d363"
               requirePermission="false" />
    </sectionGroup>
  </configSections>
  <fileUploadGroup>
    <fileUpload configSource="Web.FileUpload.config" />
  </fileUploadGroup>
  ...
</configuration>

Now add a config file into the path you set above (e.g. Web.FileUpload.config) and make your settings within the fileUpload section. Example:

<?xml version="1.0"?>
<fileUpload storageContext="Filesystem" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:name="urn:fileupload-schema" xsi:noNamespaceSchemaLocation="Web.FileUpload.xsd" >
  <fileSystem filesRoot="~/Uploads" />
</fileUpload>

####Conclusion This example shows how to include a separate config file, so you can use it with 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 include the schema file (Web.FileUpload.xsd) into your root folder, otherwise schema validation and Visual Studio Intelligence won't work. Make sure you have the appropriate write permissions.

Code

Code examples: Example03


License

Backload. (Standard version): Copyright 2013, Steffen Habermehl, License (Standard version): MIT license
Professional and Enterprise (source code) version are available under a commercial license.
Follow us on Twitter: @Backload_MVC

Clone this wiki locally