Udostępnij za pośrednictwem


Moving to the Commerce Server Application on .NET Framework

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

To make a smooth migration from Commerce Server 2002 applications that use Active Server Pages (ASP) and the Component Object Model (COM) to Commerce Server 2007 applications that use ASP.NET, you must understand the Commerce Server Class Library and the .NET-connected application Framework components and their interrelations.

Some Commerce Server functionality relies on COM components. Because applications written for the .NET Framework cannot communicate directly with COM components, the .NET Framework provides an Interop layer. This layer enables Commerce Server applications that use ASP.NET to access the Commerce Server functionality that still relies on COM.

This topic describes the programmatic components of the Commerce Server Application Framework. It then provides an overview of the Commerce Modules that includes guidance on when to build them and how to enable them in the Web.config file.

Components of Commerce Server Applications on .NET Framework

The .NET Application Framework includes the Commerce Server Class Library. This library uses an application runtime that simplifies building new Commerce Server applications.

The .NET-connected application Framework also includes the common language runtime (CLR) Interop Layer. Internally, many of the classes in the Commerce Server Class Library use Commerce Server COM objects. The Interop Layer makes these COM components available from the CLR by providing a programming model for those components that is consistent with the Common Language Specification (CLS) and with the .NET Framework design guidelines.

The CLR Interop Layer is composed of Primary Interop Assemblies (PIA) that map COM object members to equivalent members in the Commerce Server Class Library. The Commerce Server Class Library uses the PIAs to interoperate with Commerce Server 2007 core services.

Note

In Commerce Server 2007, the PIAs for the Catalog and Orders Systems have been removed, because these systems have been redeveloped in managed code.

You should use the Commerce Server Class Library instead of using the PIAs directly. The CLR Interop Layer does not manage the lifetime of a COM object for you. Instead, the Commerce Server Class Library does this, which achieves increased performance and stability.

Commerce Modules

Commerce Modules are an extension of the CLR, and are based on the HTTP module architecture that the runtime provides. Commerce Modules are responsible for initializing run-time services specific to .NET-based Commerce Server applications. The CommerceModule class is the base class from which all Commerce Modules derive. After an application is loaded into the Commerce Server Application runtime, you can use the CommerceContext class to access all page-scope and application-scope components that are provided by Commerce Server from the Global.asax file, a Web Forms page, or any custom component.

Using Commerce Modules reduces the code you need to write in the Global.asax file and in ASP.NET pages to initialize components. The initialization code is encapsulated in Commerce Modules that read configuration data from the Web.config file.

Some Commerce Modules are configurable and some are not. If the Commerce Module is configurable, the module implements the associated IConfigurationSectionHandler interface that are defined in the <sectionGroup name="Commerce Server"> section of the Web.config file. Commerce Modules are defined and initialized in the <httpModules> section of the Web.config file.

The following table contains a description of the Commerce Modules available in Commerce Server 2007.

Commerce Module

Description

CommerceApplicationModule

Provides the base class for all Commerce Modules. By definition, an application must use CommerceApplicationModule to be compatible with the .NET Framework and the Commerce Server Class Library.

CommerceAuthenticationModule

Provides an infrastructure that manages authentication of site users. The module manages client-side cookies and creates an instance of AuthManagerInfo available at the page level. This is only needed if you are using AuthManager for authentication. It is not needed for ASP.NET Membership Provider-based authentication.

CommerceCacheModule

Creates the collection of CacheManager caches used on the site.

CommerceCatalogModule

Creates a default CatalogContext object for the site.

CommerceDataWarehouseAuthenticationModule

Use instead of the CommerceAuthenticationModule if AuthManager is not used, but DWA user reports are used.

CommerceOrderModule

Creates a default OrderContext object for the site.

CommerceProfileModule

Creates a default ProfileContext object for the site.

CommerceContentSelectionModule

Creates the collection of ContentSelectionContext objects for the site.

CommerceExpressionModule

Creates an ExpressionEvaluator component for the site.

Enabling Commerce Modules in the Web.config File

The <httpModules> section of the Web.config file contains the configuration settings for the Commerce Modules available for use in the site. The order in which the modules appear in the Web.config file is significant. Any module dependent on another module must be listed after the module on which it is dependent.

Because the CommerceApplicationModule class is required for an application to be considered part of a Commerce Server .NET Framework application, it must be listed before all other CommerceModule classes in the <httpModules> section.

Building Custom Commerce Modules

Although Commerce Modules are an extension to the HTTP module architecture in the .NET Framework, we recommend that you create custom modules derived from Commerce Modules instead of creating classes that directly implement the IHttpModule interface. This approach is recommended because if the classes inherit from the CommerceModule class, Commerce Server can manage the dependencies between modules in the application classes.

If you want to provide extensions or plug-ins for the Commerce Server platform, create a Commerce Module if one or more of the following are true:

  • The extension depends on a resource or resources in the Commerce Server Administration database.

  • The extension depends on other Commerce Server modules.

  • The extension requires global configuration before its functionality is used on site pages.

  • The extension must subscribe to request processing events raised by the HttpApplication class.

  • Other Commerce Modules might depend on this module being configured as a Commerce Module in the Web.config file.

See Also

Other Resources

About Commerce Server 2002 ASP-based Site Migration to Commerce Server 2007