Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

module.config

Describes the <module> section of the module.config file, which is located in the root directory of a shell module and contains settings specific to that module.

The Configuration topic describes the syntax used in the description of the configuration elements.

<module>
  <assemblies/>
  <routes/>
  <clientResources/>
  <dojo/>
  <clientModule/>
</module>

<module>

<module helpFile="string"
        productName="string"
        clientResourceRelativePath="string"
        type="string">
	<assemblies/>
	<routes/>
	<clientResources/>
	<dojo/>
	<clientModule/>
</module>

<module> element attributes

NameDefault valueDescription
helpFile URL to the help file for this module. {culture}, {major}, {minor}, {build}, {revision} are replaced.
productName A product name for display. If this is not specified, the module name is used.
clientResourceRelativePath The client module resource relative path is combined with the resource base path and is used specifically for paths to client resources. If not defined the resource base path is used as-is. One use for this is versioning the client resources in a module.
type The type specifies which class to instantiate for this module instance. If this is not set, ShellModule is used.
loadFromBintrueWhether to load all assemblies from the bin folder of the module. Otherwise, only assemblies listed under the assemblies element are loaded.
routeBasePathOptional base path for routes to the module. 
viewFolderOptional name of the folder containing views for the module. If not given, the expectation is that the views are in a folder named <moduleName>.Views.
authorizationPolicy"DefaultShellModulePolicy"Specifies which policy that should be applied to the module. If not specified then a default policy that requires any of the roles WebEditors, WebAdmins, CmsAdmins, or Administrators.
moduleJsonSerializerTypeJsonSerializerType.ResolveSpecifies which JSON serializer the module should use. JsonSerializerType enum has the following values:

- Resolve – If the shell module contains any Newtonsoft JSON converter registered in the DI container, Newtonsoft is used as a serializer. Otherwise, the .Net Core built-in one is used.
- Newtonsoft – A Newtonsoft serializer is used.
- Net – The .Net Core built-in serializer is used.
- None – None-specific serializer is registered for the module. Useful for example if the module registers a custom serializer (such as Newtonsoft or the built-in serializer with custom settings) through code.
preferredUiJsonSerializerTypeJsonSerializerType.ResolveSpecifies which JSON serializer the CMS UI should use. This can be configured if the module is part of CMS UI serialization, for example, through custom types. JsonSerializerType enum has the following values:

- Resolve – If the shell module contains any Newtonsoft JSON converter registered in the DI container, Newtonsoft is used as a serializer. Otherwise, the .Net Core built-in one is used.

- Newtonsoft – A Newtonsoft serializer is used.

- Net – The .Net Core built-in serializer is used.

- None – None-specific serializer is registered for the module. Useful for example if the module registers a custom serializer (such as Newtonsoft or the built-in serializer with custom settings) through code.

<assemblies>

This list of assemblies specifies which assemblies belong to this shell module.

<assemblies>
  <add assembly="string" />
    ...
</assemblies>

<add> element attribute

NameDefault valueDescription
assembly Required – The name of an assembly that should be loaded and associated with the module.

<routes>

<routes>
	<route url="string"
         clientSideOnly="string"
         type="string"
         controllerPrefix="string">
		<defaults>
			<add key="string"
           value="string" />
          ...
        
		
		</defaults>
		<constraints>
			<add key="string"
           value="string" />
          ...
        
		
		</constraints>
		<dataTokens>
			<add key="string"
           value="string" />
          ...
        
		
		</dataTokens>
	</route>
      ...
    

</routes>

<route> element attributes

NameDefault valueDescription
url`moduleArea}/{controller}/{action}/{id}The URL pattern for the route. See the Route.Url property for details on how the ASP.NET routing system uses these values. URL parameters are enclosed in braces ({}).
clientSideOnlyfalseDetermines whether this route only affects the client routing model.
type The fully-qualified name of the class to instantiate for routing instead of Route. The class must inherit RouteBase.
controllerPrefix A prefix applied to controllers routed to this route. This makes it possible to “scope” controllers without conflict with application controllers.

<defaults>/<add> element attributes

These values specify the default values used when the request does not define URL parameters (see the URL attribute on the route element). See the Route.Defaults property for details on how the ASP.NET routing system uses these values.

NameDefault valueDescription
key Required – Parameter name
value Required – Default value for this parameter

<clientResources>

This section contains definitions of client resources that should be associated with the module.

<clientResources>
	<add name="string"         
       path="string"         
       resourceType="string"
       sortIndex="int"
       isMinified="bool" >
		<dependencies>
			<add name="string" />
        ...
    
		</dependencies>
	</add>
    ...

</clientResources>

<add> element attributes

This is the client resource definition.

NameDefault valueDescription
name Required – The name of the client resource. This is used as the key when loading resources. Several resources can share the same name if they should be grouped.
path Required – The virtual path to the resource on this site or a well-formed URL to an external resource. If the virtual path is relative or partial, it is automatically resolved based on the client resource base and relative paths of the module.
resourceType Required – Specifies the resource type, which must be either Script or Style.
sortIndex0Use the sort index to specify dependencies between resources with the same name.
isMinifiedfalseIndicates whether the content of this client resource is already minified.

<dependencies>/<add> element attributes

The list of names of client resources that this resource depends on.

NameDefault valueDescription
name Required – The name of the client resource that this resource depends on.

<dojo>

This section contains configuration for paths and aliases used by Dojo.

<dojo>
  <paths>
    <add name="string" path="string" />
  </paths>
  <aliases>
    <add from="string" to="string" />
  </aliases>
</dojo>

<paths>/<add> element attributes

NameDefault valueDescription
name Required – Dojo module identifier fragment. (For example: epi/cms)
pathScripts/[Name]Path to the module root.

<aliases>/<add> element attributes

Aliases let module paths be remapped at run time.

NameDefault valueDescription
from Required – Module path under Dojo 1.7 (for example, epi/cms/contentediting/editors/SelectionEditor).
to Required – Module path under Dojo 1.8 (for example, epi-cms/contentediting/editors/SelectionEditor).

<clientModule>

This section contains client-side configuration options.

<clientModule initializer="string">
  <moduleDependencies>
    <add dependency="string"/>
      ...
  </moduleDependencies>
  <requiredResources>
    <add name="string"/>
      ...
  </requiredResources>
      ...
</clientModule>

<clientModule> element attributes

NameDefault valueDescription
initializer The (JavaScript) class, which has the initializer for starting the module on the client. This should inherit from the base class epi/_Module.

Example of client-side initializer class

define(["dojo/_base/declare"], function (declare) {
  return declare([], {
    initialize: function () {
      // Do any custom module initialization here
    }
  });
});

<moduleDependencies>/<add> element attributes

Defines shell modules that this module has a dependency on the client side.

NameDefault valueDescription
dependency Name of shell module that this (client-side) module depends on.
typeRequireType of dependency. The options are:

- Require – indicates that the named module needs to be started before this module.
- RunAfter – starts automatically after the named module has started.
It is also possible to combine the above options.

<requiredResources>/<\add> element attributes

This section defines which client resources should be loaded on the client.

NameDefault valueDescription
name The name of the client resource that is required and should be loaded. This refers to the name attribute in clientResources.

Application default module

In addition to the ordinary shell modules, there is also a module configured for the application. This module serves two main purposes: resolving paths to the wwwroot when no matching module is found in the module system, enabling the application to provide functionality that would otherwise require a separate module implementation.

This default module is added to the module system as an empty module. To configure it, place a module.config file in the application root. This module.config is treated like any other module configuration except that the client resource base path is defaulted to wwwroot/ClientResources, unless configured otherwise.

Example module manifest file

<?xml version="1.0" encoding="utf-8" ?>
<module productName="Sample Module" clientResourceRelativePath="7.3.0" loadFromBin="false">
	<assemblies>
		<add assembly="Sample.UI" />
	</assemblies>
	<route controllerPrefix="Sample">
		<defaults>
			<add key="moduleArea" value="Sample.UI" />
			<add key="controller" value="Home" />
			<add key="action" value="Index" />
		</defaults>
	</route>
	<clientResources>
		<add name="sample.theme" path="ClientResources/sample.css" resourceType="Style" />
		<add name="sample.widgets" path="ClientResources/widget1.js" resourceType="Script">
			<dependencies>
				<add name="sample.dependency" />
			</dependencies>
		</add>
		<add name="sample.widgets" path="ClientResources/widget2.js" resourceType="Script" sortIndex="1" />
		<add name="sample.other" path="http://domain.com/Script.js" resourceType="Script" />
	</clientResources>
	<dojo>
		<paths>
			<add name="sample" path="ClientResources"/>
		</paths>
	</dojo>
	<clientModule>
		<moduleDependencies>
			<add dependency="Shell"/>
			<add dependency="CMS" type="RunAfter"/>
			<add dependency="AnotherAddon" type="Require RunAfter"/>
		</moduleDependencies>
		<requiredResources>
			<add name="sample.theme"/>
			<add name="sample.widgets"/>
		</requiredResources>
	</clientModule>
</module>