ASPxHttpHandlerModule
- 5 minutes to read
ASP.NET’s built-in HTTP Handler and Module generates one HTTP request per file and loads these files sequentially when a browser loads a web page. If a web page contains many files (such as scripts, styles, binary data, etc.), its loading can take a significant amount of time.
The DevExpress ASP.NET subscription includes the ASPxHttpHandlerModule (the DevExpress HTTP Handler and Module) that is implemented instead of the standard HTTP Resource handler and increases a web page’s loading speed.
The ASPxHttpHandlerModule can function as both a handler and a module.
- ASPxHttpHandlerModule Registration
- ASPxHttpHandlerModule as a Module
- ASPxHttpHandlerModule as a Handler
- WebResourceAssembly Attribute
ASPxHttpHandlerModule Registration
Register the ASPxHttpHandlerModule by automatically or manually adding configuration strings to the following Web.Config file sections:
- system.web/httpHandlers and system.webServer/handlers (for IIS7 and newer versions in integrated mode) - Register it as a handler
- system.web/httpModules and system.webServer/modules (for IIS7 and newer versions in integrated mode) - Register it as a module
Automatic registration
You can automatically register the ASPxHttpHandlerModule as a module and a handler by adding the required strings to the sections described above in the following cases:
- When creating a web application with DevExpress project templates;
- When adding a DevExpress web control to a form in Design View or switching to it after adding a control in Source View.
Manual registration
You can add the following strings to the Web.Config file if the ASPxHttpHandlerModule is not registered automatically:
For version 14.2 and newer
IIS (classic mode)
<system.web>
...
<httpHandlers>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v19.1, Version=19.1.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET"
path="DX.ashx" validate="false" />
</httpHandlers>
<httpModules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v19.1, Version=19.1.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
</httpModules>
...
</system.web>
IIS7 and newer (integrated mode)
<system.web>
...
<httpHandlers>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v19.1, Version=19.1.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET"
path="DX.ashx" validate="false" />
</httpHandlers>
<httpModules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v19.1, Version=19.1.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
</httpModules>
...
</system.web>
<system.webServer>
...
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v19.1, Version=19.1.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" name="ASPxHttpHandlerModule"
path="DX.ashx" preCondition="integratedMode" />
</handlers>
<modules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v19.1, Version=19.1.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
</modules>
...
</system.webServer>
Note that you should specify your PublicKeyToken (PublicKeyToken=b88d1754d700e49a” in the example), assembly version (Version=19.1.16.0), and assembly name (DevExpress.Web.v19.1) in these strings.
For version 14.1 and older
IIS (classic mode)
<system.web>
...
<httpHandlers>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET"
path="DX.ashx" validate="false" />
</httpHandlers>
<httpModules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
</httpModules>
...
</system.web>
IIS7 and newer (integrated mode)
<system.web>
...
<httpHandlers>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET"
path="DX.ashx" validate="false" />
</httpHandlers>
<httpModules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
</httpModules>
...
</system.web>
<system.webServer>
...
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" name="ASPxHttpHandlerModule"
path="DX.ashx" preCondition="integratedMode" />
</handlers>
<modules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v14.1, Version=14.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
</modules>
...
</system.webServer>
Note that you need to specify your PublicKeyToken (PublicKeyToken=b88d1754d700e49a” in the example), assembly version (Version=14.1.8.0), and assembly name (DevExpress.Web.v14.1) in these strings.
Tip
You may also need to register the reporting HTTP handlers if you use reporting controls in your ASP.NET application. See the Registering ASPxHttpHandlerModule for Reporting Controls topic for more information.
ASPxHttpHandlerModule as a Module
The ASPxHttpHandlerModule has access to ASP.NET application lifecycle events (it is subscribed to an application’s PreSendRequestHeaders and AuthenticateRequest events) and can assess incoming requests and modify outbound responses. For example, it can handle server-side exceptions and standard response redirection, as well as check authentication expiration.
The primary ASPxHttpHandlerModule features are listed below.
- Process callback requests from DevExpress web controls, compress callbacks and resolve exceptional situations that may arise during callback processing. See Overview - Callback Exception Handling for more information.
- Obtain binary data (DevExpress Gauges, Charts, and ASPxBinaryImage controls) from the server without loading the page’s hierarchy.
- Integrate DevExpress web controls into a SharePoint page.
- Merge and compress resources (script and CSS files) on the server before posting to the client.
- Shorten resource URLs, thereby reducing the overall HTML render.
- Support the DevExpress theming mechanism.
Note
You can manipulate specific DevExpress options within the Web.Config file to affect how ASPxHttpHandlerModule forms respond. Refer to the Web.Config Options Overview topic to learn more.
ASPxHttpHandlerModule as a Handler
The optional ASPxHttpHandlerModule handler’s functionality allows you to merge and compress custom CSS and JavaScript source files. See How to: Merge and Compress Custom CSS and JavaScript Files to learn more.
Note
The enableResourceCompression option must be set to true (the default value) to enable file compression.
WebResourceAssembly Attribute
When you create a custom assembly that contains DevExpress resources, set the WebResourceAssembly(assemblyID) attribute - to specify that the assembly can export resources via the ASPxHttpHandlerModule. Set the assemblyID attribute to a value greater than 100 to avoid conflicts (key values from 0 to 100 are reserved for DevExpress controls).
The complete sample project is available at How to create a custom theme assembly.