Introduction
The majority of companies today integrate various technologies in the software world. To operate these services, they were able to relate well with one another. Liferay 7.4 is a technology that allows developing websites, portals, and digital experiences. It also supports the use of REST APIs that assist other systems in interacting with it.
.NET applications can be connected to Liferay 7.4 by a .NET Client Extension. It describes itself as a bridge, an aid that allows the engineers of .NET to avail the capabilities of Liferay, including user management, content management, objects, and workflow management, in their non-Java projects.
Liferay-Layers This extension is based on the principle of secure API calls made via the REST protocol, and this implies that your .NET application is able to exchange data with Liferay without being constrained by its internal design. It assists in an easy and effective collaboration of your .NET application and Liferay.
Prerequisites
Liferay DXP/Portal 7.x
Basic knowledge of Liferay Workspace
Understanding of Liferay’s Headless APIs
Code editor or IDE (Eclipse, IntelliJ IDEA, Visual Studio, or other developer tools)
Environmental Requirements
Running instance of Liferay Portal or DXP
.NET SDK (version 6.0 or higher)
Why Use a DotNet Client Extension?
A DotNet Client Extension makes it easy for .NET developers to connect their applications with Liferay 7.4. Here’s why it’s useful :
Works across platforms : You can easily connect your existing .NET systems with Liferay services.
Keep your main logic in .NET : Use Liferay’s APIs without changing your main .NET code or structure.
Scalable and flexible : Build small, independent microservices that communicate with Liferay without overloading your main system.
Secure communication : Use OAuth2 or API tokens to safely connect with Liferay’s APIs.
Best on enterprise apps : Useful to connect the backend of Liferay with .NET-based systems such as ERP, CRM, or HR systems or analytics.
Simply put, a DotNet Client Extension assists you in extending the features of Liferay with the help of .NET, in a safe and easy way, and without affecting the inner code of Liferay.
How to Integrate .NET Client Extension with Liferay?
In order to use a .NET Client Extension with Liferay 7.4, you have to initially establish a connection between your .NET application and the REST APIs of Liferay. This allows your .NET application to carry on safe and effective operations of obtaining users and controlling content and processes.
Step 1 : Set Up Your Environment
Make sure you have the following ready before starting :
A running instance of Liferay 7.4 (Portal or DXP)
.NET SDK (6.0 or higher) installed
Step 2 : Create a new ASP.NET Core Web API project(Using Terminal)
dotnet new webapi -n dotnet-api-client-extension
cd dotnet-api-client-extension
Step 3 : Add necessary NuGet packages
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer
dotnet add package System.IdentityModel.Tokens.Jwt
dotnet add package Microsoft.IdentityModel.Tokens
dotnet add package Newtonsoft.Json
Step 4 : Configure appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ReadyPath": "/ready",
"Domains": [ "http://localhost:58084", "http://localhost:8080", "http://localhost:5173" ],
"Liferay": {
"MainDomain": "localhost:8080",
"ServerProtocol": "http",
"OAuthAppExternalReferenceCode": "dotnet-oauth-application-user-agent",
"OAuthJWKSUri": "/o/oauth2/jwks"
}
}
Step 5 : Create a client-extension.yaml file
assemble:
- include:
- "**/*.cs"
- appsettings.json
dotnet-oauth-application-user-agent:
.serviceAddress: localhost:58084
.serviceScheme: http
name: DotNet OAuth Application User Agent
scopes:
- Liferay.Headless.Admin.Workflow.everything
type: oAuthApplicationUserAgent
dotnet-object-action-1:
name: DotNet Object Action 1
oAuth2ApplicationExternalReferenceCode: dotnet-oauth-application-user-agent
resourcePath: /dotnet/object/action/1
type: objectAction
Step 6 : Configure CORS and JWT Middleware
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Net.Http.Json;
using System.Text.Json;
var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration;
// Configure CORS
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowLiferay", policy =>
{
policy.WithOrigins(config.GetSection("Domains").Get())
.AllowAnyHeader()
.AllowAnyMethod();
});
});
// Add JWT authentication
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Events = new JwtBearerEvents
{
OnMessageReceived = context =>
{
var authHeader = context.Request.Headers["Authorization"].ToString();
if (!string.IsNullOrEmpty(authHeader) && authHeader.StartsWith("Bearer "))
{
context.Token = authHeader["Bearer ".Length..].Trim();
}
return Task.CompletedTask;
},
OnTokenValidated = async context =>
{
var httpClient = new HttpClient();
var liferayConfig = config.GetSection("Liferay");
var jwksUri = $"{liferayConfig["ServerProtocol"]}://{liferayConfig["MainDomain"]}{liferayConfig["OAuthJWKSUri"]}";
var jwksResponse = await httpClient.GetFromJsonAsync(jwksUri);
},
OnAuthenticationFailed = context =>
{
context.Response.StatusCode = 401;
return Task.CompletedTask;
}
};
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = false,
ValidateAudience = false,
ValidateLifetime = false,
ValidateIssuerSigningKey = true
};
});
builder.Services.AddControllers();
var app = builder.Build();
app.UseCors("AllowLiferay");
app.UseAuthentication();
app.UseAuthorization();
app.MapGet(config["ReadyPath"], () => "READY");
app.MapPost("/dotnet/object/action/1", async (HttpContext ctx) =>
{
var json = await ctx.Request.ReadFromJsonAsync
Step 7 : Run the API
dotnet run
- Test /ready → should return “READY”.
- Test /sample/object/action/1 with JWT from Liferay → should accept and return the JSON.

Conclusion
By using a .NET Client Extension along with Liferay, one can easily connect Liferay with .NET-based applications. Developers are also able to use Liferay with their preferred technology stack using secure OAuth2 authentication and REST APIs, and with all the capabilities provided by Liferay. This solution eases the process of integrating the enterprises and advances the scale, as well as the clean architecture, which enables both systems to cooperate with one another effectively and steadily.