NetCoreKit.CleanResponse 1.0.1

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

NetCoreKit.CleanResponse

A lightweight and simple Result Wrapper library for .NET applications.

NetCoreKit.CleanResponse helps developers create consistent and standardized API responses for both success and failure scenarios.

Instead of returning different response structures in every API endpoint, this library ensures a single predictable response format across your application.


Installation

Install the package using NuGet:

dotnet add package NetCoreKit.CleanResponse

Why Use NetCoreKit.CleanResponse?

Without a response wrapper, APIs often return inconsistent responses.

Example:

{ "name": "John" }

or

{ "error": "User not found" }

Different response formats make frontend integration and error handling difficult.

Using NetCoreKit.CleanResponse, your APIs always return a consistent structure:

{
  "success": true,
  "message": "User fetched successfully",
  "data": {
    "name": "John"
  }
}

Response Structure

Every response generated by this library follows this format:

{
  "success": true,
  "message": "Operation completed",
  "data": {}
}

Field Description:

Field Description
success Indicates whether the operation succeeded
message A message describing the result
data The data returned by the operation

Getting Started

Import the namespace in your project:

using NetCoreKit.CleanResponse;

Usage Examples

1. Success Response With Data

var user = new User { Name = "John" };

return Result<User>.SuccessResult(user, "User fetched successfully");

Response:

{
  "success": true,
  "message": "User fetched successfully",
  "data": {
    "name": "John"
  }
}

2. Failure Response

return Result<string>.Failure("User not found");

Response:

{
  "success": false,
  "message": "User not found",
  "data": null
}

3. Success Response Without Data

return Ok(Result.SuccessResult("Operation completed successfully"));

Response:

{
  "success": true,
  "message": "Operation completed successfully"
}

4. Failure Response Without Data

return Ok(Result.Failure("Operation failed"));

Response:

{
  "success": false,
  "message": "Operation failed"
}

Example Usage in ASP.NET Controller

[HttpGet]
public IActionResult GetUser()
{
    var user = new User
    {
        Name = "John"
    };

    return Ok(Result<User>.SuccessResult(user, "User fetched successfully"));
}

Benefits

  • Standardized API responses
  • Cleaner controller code
  • Simplified success and failure handling
  • Easy integration with ASP.NET APIs
  • Reusable across multiple projects
  • Reduces repetitive response models

Target Framework

This package supports modern .NET applications and works seamlessly with ASP.NET APIs.


Contributing

Contributions, issues, and feature requests are welcome.

If you'd like to improve this project, feel free to submit a pull request.


License

MIT License


Author

Created and maintained by Pawan Dhekwar

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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.
  • net8.0

    • No dependencies.

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.0.1 116 3/16/2026
1.0.0 107 3/16/2026