LMSPro.AspNetCore 10.4.0

dotnet add package LMSPro.AspNetCore --version 10.4.0
                    
NuGet\Install-Package LMSPro.AspNetCore -Version 10.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LMSPro.AspNetCore" Version="10.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LMSPro.AspNetCore" Version="10.4.0" />
                    
Directory.Packages.props
<PackageReference Include="LMSPro.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LMSPro.AspNetCore --version 10.4.0
                    
#r "nuget: LMSPro.AspNetCore, 10.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LMSPro.AspNetCore@10.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LMSPro.AspNetCore&version=10.4.0
                    
Install as a Cake Addin
#tool nuget:?package=LMSPro.AspNetCore&version=10.4.0
                    
Install as a Cake Tool

Lms.AspNetCore

NuGet NuGet Download

Lms.AspNetCore is the core ASP.NET Core integration package for the LMS Framework. It provides seamless integration between the LMS Framework and ASP.NET Core applications, offering essential features for building modern web applications.

Features

🚀 Core Integration

  • ASP.NET Core Module System: Seamless integration with LMS module architecture
  • Dependency Injection: Castle Windsor integration with ASP.NET Core DI container
  • Configuration Management: Centralized configuration system
  • Plugin Support: Dynamic assembly loading and plugin management

🔐 Security & Authentication

  • Anti-Forgery Protection: Enhanced CSRF protection with custom token management
  • Security Headers: Automatic security headers middleware
  • Principal Access: Integrated user principal management
  • Authorization: Advanced authorization mechanisms

🏢 Multi-Tenancy

  • Domain-based Resolution: Automatic tenant resolution from domain names
  • Header-based Resolution: Tenant identification via HTTP headers
  • Cookie-based Resolution: Tenant resolution using cookies
  • Caching: Efficient tenant resolution caching

📝 MVC Enhancements

  • Controller Conventions: Automatic controller registration and configuration
  • Model Binding: Enhanced model binding capabilities
  • Exception Handling: Centralized exception handling middleware
  • Validation: Integrated validation system
  • Auditing: Automatic action auditing

🌐 Localization

  • Request Culture Providers: Multiple culture resolution strategies
  • User-specific Localization: Per-user language preferences
  • Header-based Localization: Language detection from HTTP headers

⚡ Performance & Caching

  • Response Caching: Intelligent response caching mechanisms
  • Per-user Caching: User-specific cache management
  • Cache Invalidation: Automatic cache invalidation strategies

🔄 Unit of Work

  • Transaction Management: Automatic transaction handling
  • Middleware Integration: UoW pattern integrated with ASP.NET Core pipeline
  • Configurable Options: Flexible UoW configuration

Installation

Package Manager Console

Install-Package LMSPro.AspNetCore

.NET CLI

dotnet add package LMSPro.AspNetCore

PackageReference

<PackageReference Include="LMSPro.AspNetCore" Version="10.4.0" />

Quick Start

1. Basic Setup

using Lms.AspNetCore;
using Lms.Castle.Logging.Log4Net;

[DependsOn(
    typeof(LmsAspNetCoreModule),
    typeof(LmsCastleLog4NetModule)
)]
public class MyWebModule : LmsModule
{
    public override void PreInitialize()
    {
        // Configure your application
    }

    public override void Initialize()
    {
        IocManager.RegisterAssemblyByConvention(typeof(MyWebModule).GetAssembly());
    }
}

2. Startup Configuration

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddLms<MyWebModule>(options =>
        {
            // Configure LMS options
            options.IocManager.IocContainer.AddFacility<LoggingFacility>();
        });

        services.AddMvc().AddLms();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseLms(options =>
        {
            options.UseUnitOfWork();
        });

        app.UseRouting();
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }
}

3. Controller Example

using Lms.AspNetCore.Mvc.Controllers;
using Lms.Web.Models;

public class HomeController : LmsController
{
    public async Task<IActionResult> Index()
    {
        return View();
    }

    [HttpPost]
    public async Task<JsonResult> CreateUser(CreateUserInput input)
    {
        // Automatic validation, auditing, and UoW
        var user = await _userService.CreateAsync(input);
        return Json(new AjaxResponse { Result = user });
    }
}

Advanced Configuration

Multi-Tenancy Setup

public override void PreInitialize()
{
    Configuration.MultiTenancy.IsEnabled = true;
    
    // Configure tenant resolvers
    Configuration.Modules.LmsAspNetCore().MultiTenancy.DomainFormat = "{0}.myapp.com";
    Configuration.Modules.LmsAspNetCore().MultiTenancy.TenantIdResolveKey = "TenantId";
}

Security Configuration

public override void PreInitialize()
{
    Configuration.Modules.LmsAspNetCore().CreateControllersForAppServices = true;
    Configuration.Modules.LmsAspNetCore().DefaultUnitOfWorkAttribute.IsTransactional = false;
    
    // Configure anti-forgery
    Configuration.Modules.LmsWeb().AntiForgery.IsEnabled = true;
    Configuration.Modules.LmsWeb().AntiForgery.TokenName = "__RequestVerificationToken";
}

Localization Setup

public void ConfigureServices(IServiceCollection services)
{
    services.Configure<RequestLocalizationOptions>(options =>
    {
        var supportedCultures = new[] { "en", "vi", "zh-CN" };
        options.SetDefaultCulture(supportedCultures[0])
               .AddSupportedCultures(supportedCultures)
               .AddSupportedUICultures(supportedCultures);

        options.RequestCultureProviders.Insert(0, new LmsUserRequestCultureProvider());
    });
}

Custom Exception Handling

public void Configure(IApplicationBuilder app)
{
    app.UseLms(options =>
    {
        options.UseExceptionHandling();
        options.UseUnitOfWork();
        options.UseSecurityHeaders();
    });
}

Key Components

Modules

  • LmsAspNetCoreModule: Main module for ASP.NET Core integration
  • Configuration: Centralized configuration management
  • Dependency Injection: Castle Windsor integration

Middleware

  • UnitOfWorkMiddleware: Automatic transaction management
  • ExceptionHandlingMiddleware: Centralized exception handling
  • SecurityHeadersMiddleware: Security headers injection
  • AuthorizationExceptionHandlingMiddleware: Authorization error handling

Services

  • AspNetCorePrincipalAccessor: User principal management
  • HttpContextClientInfoProvider: Client information extraction
  • AspNetCoreWebhookSender: Webhook delivery system

Multi-Tenancy Resolvers

  • DomainTenantResolveContributor: Domain-based tenant resolution
  • HttpHeaderTenantResolveContributor: Header-based tenant resolution
  • HttpCookieTenantResolveContributor: Cookie-based tenant resolution

Best Practices

1. Controller Design

// Inherit from LmsController for automatic features
public class ProductController : LmsController
{
    private readonly IProductAppService _productService;

    public ProductController(IProductAppService productService)
    {
        _productService = productService;
    }

    [HttpGet]
    public async Task<IActionResult> GetAll()
    {
        var products = await _productService.GetAllAsync();
        return Json(new AjaxResponse { Result = products });
    }
}

2. Exception Handling

// Use UserFriendlyException for user-facing errors
if (user == null)
{
    throw new UserFriendlyException("User not found!");
}

// Use LmsValidationException for validation errors
if (input.Email.IsNullOrEmpty())
{
    throw new LmsValidationException("Email is required!");
}

3. Auditing Configuration

[Audited]
public class UserController : LmsController
{
    [DisableAuditing]
    public IActionResult GetUserPhoto(int userId)
    {
        // This action won't be audited
        return File(photoBytes, "image/jpeg");
    }
}
  • Lms: Core framework
  • Lms.Web.Common: Common web utilities
  • Lms.AspNetCore.SignalR: SignalR integration
  • Lms.AspNetCore.OData: OData support
  • Lms.AspNetCore.TestBase: Testing utilities

Documentation

For more detailed documentation, visit:

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Statistics

  • Target Framework: .NET 9.0
  • Package ID: LMSPro.AspNetCore
  • Dependencies: Castle.Windsor, ASP.NET Core MVC
  • Assembly: Lms.AspNetCore.dll
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.4.0 124 8/18/2025