Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Converter Class

Represents a configuration element in a configuration file.

Namespace:  System.Web.Configuration
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Converter : ConfigurationElement

The Converter class enables you to programmatically access and modify the configuration settings related to converters that are used by AJAX-enabled ASP.NET applications.

To create custom conversion functionality, you can create a class that inherits from the JavaScriptConverter class. After the converter has been created, you can register it for use in the configuration file of your Web application.

The following configuration file excerpt shows how to declaratively specify values for properties of the Converter class.

<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization>
        <converters>
          <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter" />
        </converters>
      </jsonSerialization>
    </webServices>
  </scripting>
</system.web.extensions>

The following example demonstrates how to access Converter programmatically.

// Get the Web application configuration.
System.Configuration.Configuration configuration =
    WebConfigurationManager.OpenWebConfiguration("/aspnetTest");

// Get the external JSON section.
ScriptingJsonSerializationSection jsonSection =
    (ScriptingJsonSerializationSection)configuration.GetSection(
    "system.web.extensions/scripting/webServices/jsonSerialization");

//Get the converters collection.
ConvertersCollection converters =
    jsonSection.Converters;

if ((converters != null) && converters.Count > 0)
{
    // Get the first registered converter.
    Converter converterElement = converters[0];
}
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.