BaseProvider.Initialize Method
Retrieves user-specified configuration settings for the BaseProvider class.
Syntax
protected virtual void Initialize(StringDictionary config)
{
}
Protected Overridable Sub Initialize(config As StringDictionary)
End Sub
Parameters
Parameter Name | Description |
---|---|
config |
Contains a StringDictionary that contains key/value pairs from the IIS configuration settings. |
Return Value
void
Remarks
You can specify parameters for an FTP provider in the IIS applicationHost.config file by adding an <activation> collection, which may contain a series of <providerData> elements that list additional settings for custom FTP providers. Each <providerData> element is paired with an entry in the <providerDefinitions> collection, and contains a series of key/value pairs that contain information that is specific to each provider. By overriding the Initialize
method, your module can retrieve the series of key/value pairs from the configuration store.
The following configuration excerpt illustrates a custom FTP provider entry in the applicationHost.config file and its related information.
<system.ftpServer>
<providerDefinitions>
<add name="FtpDemo"
type="FtpDemo.DemoProvider,FtpDemo,version=1.0.0.0,Culture=neutral,PublicKeyToken=426f62526f636b73" />
<activation>
<providerData name="FtpDemo">
<add key="one" value="1" />
<add key="two" value="2" />
</providerData>
</activation>
</providerDefinitions>
</system.ftpServer>
Example
The following code example iterates through the array of configuration settings and sends the key/value pairs to the debug stream.
protected override void Initialize(StringDictionary config)
{
base.Initialize(config);
// List the number of configuration entries for this provider.
Debug.WriteLine("Config Entries: " + config.Count);
if (config.Count > 0)
{
// Enumerate the individual configuration entries.
foreach (DictionaryEntry entry in config)
{
// List the key name and value for each configuration entry.
Debug.WriteLine(entry.Key + ": " + entry.Value);
}
}
}
For additional examples of how to use the BaseProvider.Initialize method, see the following articles:
Create an FTP Authentication Provider with Dynamic IP Restrictions
Create an FTP Authentication and Authorization Provider using an XML Database
How to Use Managed Code (C#) to Create an FTP Provider that Prevents Leeching
Requirements
Type | Description |
---|---|
Client | - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
Server | - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 Technical Preview |
Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 |
Reference | Microsoft.Web.FtpServer.dll |