Manged Modules and Custom Modules in IIS (2024)

Table of Contents:

  1. Modules in IIS
  2. Types of Modules
  3. Integration within IIS Architecture and Pipeline
  4. Custom Module and it's creation
  5. Interference with Incoming Requests
  6. Capabilities of Custom Modules
  7. Advantages of Using Custom Modules
  8. Summary

Modules in IIS


Modules in Internet Information Services (IIS) are individual features that the server uses to process requests. Module
is a component that handles specific tasks during the processing of web requests. These tasks can range from authentication and logging to compression and caching. Modules are integral to how IIS manages and processes requests, allowing for a modular and customizable approach to web server functionality. They are designed to handle specific tasks, such as authentication, caching, logging, and more.

There are two types of Modules available :

  • Native Modules: Built into IIS and handle core functionalities like authentication, compression, and logging.
  • Managed Modules: Written in managed code (e.g., .NET) and provide additional features like session state management and URL authorization.

Modules can inspect, modify, or act on requests and responses. They participate in the request processing pipeline, ensuring tasks like user authentication, data compression, and request filtering are handled efficiently

Integration within IIS Architecture and Pipeline

Let's take a look into the IIS pipeline mode :

Integration within IIS Architecture and Pipeline

Custom modules are integrated into the IIS request-processing pipeline, which follows these stages.By subscribing to events such as `BeginRequest`, custom modules can intercept and process requests at different points in this pipeline.

Manged Modules and Custom Modules in IIS (1)

On the left side we have stages that will be part of request lifecycle. We have different stages like authentication, authorization, execute handler, compression and on the right side we have modules like basic and windows which will be subscribed to different stages.

Modules will be subscribing to different stages

Modules are loaded into the IIS pipeline and participate in the request processing. They can inspect, modify, or act on requests and responses. For example, an authentication module might verify user credentials before allowing access to a resource, while a compression module might compress the response data before sending it to the client.

So how does this works ?

Consider I have an ASP.NET framework application hosted on IIS. On this website I have enabled Windows authentication

Manged Modules and Custom Modules in IIS (2)

So here the request to my website will go via standard IIS pipeline, however as we have windows authentication enabled you will be able to see that when authentication stage is reached in the pipeline, it will check if there is any module subscribed for this stage. Once it identifies that the windows authentication is enabled it will intercept the request and will perform Windows authentication and then process the request.

If you want to see how does this looks, you can take a FREB trace and see the Windows authentication module getting kicked in under the authentication stage

Manged Modules and Custom Modules in IIS (3)

There are other modules that are not yet subscribed and not performing any activity.

This is how the Modules make IIS a flexible and powerful web server, allowing administrators and developers to tailor its behaviour to meet specific application requirements. But how is the flexibility going to be achieved ?

For that we can customize the modules as per our need.

Custom Modules

You can create your own custom modules to extend IIS functionality. These modules can be written in native code (C/C++) or managed code (C#, VB.NET). Custom modules allow for tailored solutions to specific needs, such as custom logging, authentication, or request handling.

Writing and Adding Custom Modules in IIS

Creating a custom module for IIS involves writing managed or native code that hooks into the IIS request processing pipeline. Here's a step-by-step guide:

Step 1: Create a New Class Library Project

Open Visual Studio and create a new Class Library project.

Name your project, for example, RemoveHeadersModule.

Step 2: Implement the IHttpModule Interface

Add a new class to your project, e.g., RemoveHeadersModule.cs.

Implement the IHttpModule interface in this class.

public class CustomModule : IHttpModule{public void Init(HttpApplication context){context.BeginRequest += new EventHandler(OnBeginRequest);//this is where you can add your logic to modify the request}private void OnBeginRequest(object sender, EventArgs e){HttpContext context = ((HttpApplication)sender).Context;context.Response.Write("Custom Module Executed!");}public void Dispose() { }}

For native code, use C++ to create an ISAPI extension or filter.

Step 3: Register the Module

  1. Open yourweb.configfile.
  2. Add the following configuration to register your custom module:
<configuration> <system.webServer> <modules> <add name="<AssemblyName>" type="<namespace.classname>" /> </modules> </system.webServer></configuration>


Step 4: Deploy the Module

Build your project to generate the DLL.

Copy the DLL to thebindirectory of your web application.

Ensure yourweb.configis updated with the module registration.

Interference with Incoming Requests

Custom modules can modify the behavior of incoming requests by inspecting and altering request headers, redirecting requests, or even generating responses. For example, a module can be designed to:

  • Log request details.
  • Apply custom authentication or authorization logic.
  • Modify response headers.

This can also be seen from the FREB logs

I have created a class library name :

RemoveHeadersModule and integrated it with IIS hosted application. When a FREB trace is taken, I am able to see the same request getting kicked in as :

Manged Modules and Custom Modules in IIS (4)

This is how the request can be modified as per requirement.

Capabilities of Custom Modules

Custom modules can be used for various purposes:

  • Authentication and Authorization
  • Request and Response Filtering
  • URL Rewriting
  • Custom Logging
  • Load Balancing

Advantages of Using Custom Modules

Custom modules offer several benefits:

  • Flexibility: Tailor request handling to specific needs.
  • Extensibility: Enhance IIS functionality without modifying core server code.
  • Performance: Improve request processing efficiency through specialized logic.

Summary


In conclusion, the flexibility and power of IIS as a web server are significantly enhanced by the use of modules, both native and custom. These modules allow for a highly customizable and efficient way to handle web requests, providing the ability to tailor the server's behavior to meet the specific needs of applications. Custom modules, in particular, offer the opportunity to extend IIS functionality in targeted ways, such as improving authentication processes, filtering requests and responses, and even rewriting URLs.

By leveraging the capabilities of custom modules, administrators and developers can ensure that their web server is optimized for performance, security, and reliability.

Manged Modules and Custom Modules in IIS (2024)

FAQs

How do I add a managed module in IIS? ›

In the Home pane, double-click Modules. In the Actions pane, click Add Managed Module. In the Add Managed Module dialog box, enter the name of the managed module in the Name box, and then enter or select the module's . NET Framework fully-qualified type in the Type box.

What are modules in IIS? ›

Modules are self-contained, shareable bundles of code and data. Each module manages a specific task in your infrastructure, such as installing and configuring a piece of software.

How to install module in IIS? ›

IIS modules are like building blocks, modules may be added to the server in order to provide the desired functionality for applications. Installation is done by using one of three methods on Windows - The IIS interface, AppCmd.exe and PowerShell New-WebGlobalModule.

What is rewrite module in IIS? ›

The IIS URL Rewrite module is a tool used to convert complex web addresses into consistent, memorable, URL's. The rewrite module produces URLs which are simple for users to remember and for search engines to find.

How do I add management services to IIS? ›

Select Start > Administrative Tools > Server Manager. Server Manager appears. Select Web Server (IIS) under Roles, and click Add Role Services. The Select Role Services screen appears.

How do I add a managed server? ›

To add a managed server:
  1. Access the Oracle WebLogic Administration Console.
  2. Click Lock & Edit.
  3. Under Domain Structure, expand Environment and click Servers.
  4. On the Servers table, click New.
  5. On the Create a New Server: Server Properties page: ...
  6. Review the configuration options that you have chosen.
  7. Click Finish.

What is the difference between module and handler in IIS? ›

Handlers are used to process individual endpoint requests. Handlers enable the ASP.NET framework to process individual HTTP URLs or groups of URL extensions within an application. Unlike modules, only one handler is used to process a request.

What are modules in web server? ›

General concepts​ A Kameleoon web server module is a low-level component (written in C for optimal performance) that performs variation allocation whenever an HTTP request triggers an A/B experiment. It then (internally) redirects the request to a potentially different URL corresponding to the chosen variation.

How do I know if IIS rewrite module is installed? ›

To check if the URL Rewrite extension has been correctly installed, open the Internet Information Services (IIS) Manager form for the WorkZone site. The URL Rewrite extension is displayed in the IIS section on the information (right) pane for the WorkZone site.

How to configure an IIS server? ›

To enable IIS in Windows versions with the Start menu:
  1. Click the Start menu > Administrative Tools > Server Manager.
  2. Click Add Roles.
  3. In the Add Roles wizard, select Web Server (IIS), then click Next.
  4. Choose the IIS role services to install. Click Next to accept the defaults.
  5. Add any role services as required.

How to install IIS Management Tools? ›

On the Select server roles page, expand Web Server (IIS), then Management Tools, and check the Management Service box. Click Next twice, and then click the Install button. The Web Management Service will now be installed. Now, launch the Internet Information Services (IIS) manager.

How do I add CGI module to IIS? ›

Setup
  1. On the taskbar, click Server Manager.
  2. In Server Manager, click the Manage menu, and then click Add Roles and Features.
  3. In the Add Roles and Features wizard, click Next. ...
  4. On the Server Roles page, expand Web Server (IIS), expand Web Server, expand Application Development, and then select CGI.
Mar 22, 2022

How do I know if a module is installed in IIS? ›

Checking If IIS is Installed
  1. Run the following command to query if the service w3svc exists: get-service w3svc. ...
  2. If you see the following output, it means you don't have IIS installed.
  3. Run the following command to install IIS and ASP.NET: Dism /Online /Enable-Feature /FeatureName:IIS-DefaultDocument /All.

What is the difference between redirect and rewrite in IIS? ›

Simply put, a redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. A rewrite is a server-side rewrite of the URL before it's fully processed by IIS.

What is native module in IIS? ›

A native module is a Win32 DLL that can be used to extend IIS in order to provide the desired functionality of your applications.

How do I enable IIS Management Console? ›

In this topic
  1. Open Server Manager and click Manage > Add Roles and Features. ...
  2. Select Role-based or feature-based installation and click Next.
  3. Select the appropriate server. ...
  4. Enable Web Server (IIS) and click Next.
  5. No additional features are necessary to install the Web Adaptor, so click Next.

How do I add Windows authentication module to IIS? ›

In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services. On the Select Role Services page of the Add Role Services Wizard, select Windows Authentication, and then click Next. On the Confirm Installation Selections page, click Install. On the Results page, click Close.

How do I add a managed system to Solman? ›

Start SAP Solution Manager Configuration (transaction SOLMAN_SETUP ) and choose Managed Systems Configuration Technical Systems. Select a system and choose Configure System. Follow the guided activity, in which the RFC connection is configured under Connect Managed Systems.

How do I import a package into IIS Manager? ›

Open the IIS Manager by clicking Start > Run and typing inetmgr. In IIS Manager, expand the Server node and the Sites node, then select the Default Web Site. In the right-hand Actions pane, click the Import Application... link to launch the packaging wizard.

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Carmelo Roob

Last Updated:

Views: 5834

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Carmelo Roob

Birthday: 1995-01-09

Address: Apt. 915 481 Sipes Cliff, New Gonzalobury, CO 80176

Phone: +6773780339780

Job: Sales Executive

Hobby: Gaming, Jogging, Rugby, Video gaming, Handball, Ice skating, Web surfing

Introduction: My name is Carmelo Roob, I am a modern, handsome, delightful, comfortable, attractive, vast, good person who loves writing and wants to share my knowledge and understanding with you.