MB.ResponseResult 1.1.0.1

dotnet add package MB.ResponseResult --version 1.1.0.1
                    
NuGet\Install-Package MB.ResponseResult -Version 1.1.0.1
                    
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="MB.ResponseResult" Version="1.1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MB.ResponseResult" Version="1.1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MB.ResponseResult" />
                    
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 MB.ResponseResult --version 1.1.0.1
                    
#r "nuget: MB.ResponseResult, 1.1.0.1"
                    
#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 MB.ResponseResult@1.1.0.1
                    
#: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=MB.ResponseResult&version=1.1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MB.ResponseResult&version=1.1.0.1
                    
Install as a Cake Tool

Socket Badge

MB.ResponseResult Package 📦

A standardized API response library for ASP.NET Core, featuring multi-language support and seamless integration.

👅 Installation

dotnet add package MB.ResponseResult

🚀 Quick Start

  1. Register Services (Program.cs)
#Basic Usage#
builder.Services.AddResponseResultServices();

Or

#Multiple-Language Support#
builder.Services.AddResponseResultServices(options =>
{
    options.IsMultipleLang = true; // Enable multi-language support
});

🎯 Response Breakdown

✅ Success Helpers (Built with ResponseSuccess)

Method Status Code Example
Created() 201 ApiResponse.Created(product)
Ok(data) 200 ApiResponse.Ok(user)
NoContent() 204 ApiResponse.NoContent()

❌ Error Helpers (Built with ResponseFail)

Method Status Code Example
NotFound() 404 ApiResponse.NotFound("User not found")
BadRequest() 400 ApiResponse.BadRequest(errors)
ValidationError() 422 ApiResponse.ValidationError(errors)
InternalServerError() 500 ApiResponse.InternalServerError()

🔧 Core Methods

Method Status Code Parameters Example
ResponseSuccess() Custom statusCode, message, data ApiResponse.ResponseSuccess(HttpStatusCode.Accepted, "Processing", data)
ResponseFail() Custom statusCode, message, errors, data ApiResponse.ResponseFail(HttpStatusCode.TooManyRequests, "Rate limited", errors)

🔑 Key Features

Standardized Format

All responses follow the same consistent structure:

{  
  "data": {},        // Response payload (object)  
  "message": "Operation succeeded",  // Human-readable message  
  "statusCode": 200, // HTTP status code  
  "status": true,    // Boolean success indicator  
  "errors": []       // List of errors (if any)  
}

Seamless Conversion

Convert ApiResponse to IActionResult automatically using:

.AsResult() for synchronous responses : ApiResponse.Ok().AsResult();

.AsResultAsync() for asynchronous responses : ApiResponse.Ok().AsResultAsync();

🌍 Localization (Multi-Language Support)

Localization Ready

Message keys like "Ok" or "NotFound" can be localized by implementing IResultLocalizationService.

1.Implement a IResultLocalizationService Localization Service

 public class CustomLocalizationService : IResultLocalizationService
 {
     public string GetLocalizedMessage(string messageKey, string languageCode)
     {
         //Your own logic
         
     }
 
     public Task<string> GetLocalizedMessageAsync(string messageKey, string languageCode)
     {
         //Your own logic
     }
 }

2.Register the service in the program.cs

builder.Services.AddScoped<IResultLocalizationService, CustomLocalizer>();

This README provides a quick guide to integrate and use the package effectively. Expand the documentation for advanced scenarios. 😊

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
1.1.0.1 168 5/8/2025
1.1.0 164 5/8/2025
1.0.4.5 143 3/14/2025
1.0.4.4 175 3/13/2025
1.0.4.3 177 3/11/2025
1.0.4.2 178 3/11/2025
1.0.3 182 3/10/2025
1.0.1 191 3/9/2025
1.0.0 188 3/9/2025