MB.ResponseResult 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package MB.ResponseResult --version 1.0.3
                    
NuGet\Install-Package MB.ResponseResult -Version 1.0.3
                    
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.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MB.ResponseResult" Version="1.0.3" />
                    
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.0.3
                    
#r "nuget: MB.ResponseResult, 1.0.3"
                    
#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.0.3
                    
#: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.0.3
                    
Install as a Cake Addin
#tool nuget:?package=MB.ResponseResult&version=1.0.3
                    
Install as a Cake Tool

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)
builder.Services.AddResponseResultServices(options =>
{
    options.IsMultipleLang = true; // Enable multi-language support
});

🎯 Basic Usage (Response Type Breakdown)

✅ Success Responses

Method Status Code Usage Scenario Example
ResponseCreated() 201 Resource creation success ApiResponse.ResponseCreated(product)
ResponseOk() 200 General success with/without data ApiResponse.ResponseOk("Success")
ResponseNoContent() 204 Successful operation with no content ApiResponse.ResponseNoContent()

❌ Error Responses

Method Status Code Usage Scenario Example
ResponseNotFound() 404 Resource not found ApiResponse.ResponseNotFound("User not found")
ResponseBadRequest() 400 Invalid client request ApiResponse.ResponseBadRequest(errors)
ResponseValidationError() 402 Validation failures ApiResponse.ResponseValidationError(errors)
ResponseServerError() 500 Server-side errors ApiResponse.ResponseServerError("Error")
ResponseUnauthorized() 401 Missing/invalid authentication ApiResponse.ResponseUnauthorized("Login required")
ResponseForbidden() 403 Authenticated but unauthorized ApiResponse.ResponseForbidden("Admin access required")
ResponseConflict() 409 Data conflict (e.g., duplicate entry) ApiResponse.ResponseConflict("Already exists")

🔑 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

.AsResultAsync() for asynchronous responses

🌍 Localization (Multi-Language Support)

Localization Ready

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

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
     }
 }

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