RA.Utilities.Core.Constants
10.0.0
Prefix Reserved
See the version list below for details.
dotnet add package RA.Utilities.Core.Constants --version 10.0.0
NuGet\Install-Package RA.Utilities.Core.Constants -Version 10.0.0
<PackageReference Include="RA.Utilities.Core.Constants" Version="10.0.0" />
<PackageVersion Include="RA.Utilities.Core.Constants" Version="10.0.0" />
<PackageReference Include="RA.Utilities.Core.Constants" />
paket add RA.Utilities.Core.Constants --version 10.0.0
#r "nuget: RA.Utilities.Core.Constants, 10.0.0"
#:package RA.Utilities.Core.Constants@10.0.0
#addin nuget:?package=RA.Utilities.Core.Constants&version=10.0.0
#tool nuget:?package=RA.Utilities.Core.Constants&version=10.0.0
RA.Utilities.Core.Constants
A centralized and consistent set of core constants for the RA Utilities ecosystem. This package helps streamline development, improve code readability, and reduce "magic strings" and "magic numbers" by providing a single source of truth for common values.
Getting started
You can install the package via the .NET CLI:
dotnet add package RA.Utilities.Core.Constants
Or through the NuGet Package Manager in Visual Studio.
✨ Available Constants
The package currently provides the following static classes:
BaseResponseCode
Contains integer constants for common HTTP status codes, aligning with standard web practices. This class was previously named HttpStatusCodes.
| Constant Name | Value | Category |
|---|---|---|
Success |
200 | Success (2xx) |
Created |
201 | Success (2xx) |
BadRequest |
400 | Client Error (4xx) |
Unauthorized |
401 | Client Error (4xx) |
Forbidden |
403 | Client Error (4xx) |
NotFound |
404 | Client Error (4xx) |
Conflict |
409 | Client Error (4xx) |
InternalServerError |
500 | Server Error (5xx) |
BaseResponseMessages
Contains default string messages for common API responses. This helps maintain a consistent tone and messaging for your API consumers.
| Constant Name | Message | Category |
|---|---|---|
Success |
"Operation completed successfully." | Success |
Created |
"Resource created successfully." | Success |
Updated |
"Resource updated successfully." | Success |
Deleted |
"Resource deleted successfully." | Success |
BadRequest |
"The request is invalid." | Error |
Unauthorized |
"Authentication failed or is missing." | Error |
Forbidden |
"You do not have permission to access this resource." | Error |
NotFound |
"The requested resource was not found." | Error |
Conflict |
"A conflict occurred with the current state of the resource." | Error |
InternalServerError |
"An unexpected error occurred on the server." | Error |
HeaderParameters
Contains constant strings for common HTTP header names, ensuring consistency when accessing or setting headers.
| Constant Name | Value | Description |
|---|---|---|
XRequestId |
"x-request-id" |
Used for request correlation and tracing. |
TraceId |
"trace-id" |
Used for internal tracing. |
Location |
"location" |
Used in responses to redirect or indicate the location of a new resource. |
Authorization |
"Authorization" |
Used for sending authentication credentials. |
ResponseType (enum)
This enum provides a standardized, machine-readable vocabulary for the outcome of an API operation. It is used within the JSON response body to give clients a specific, semantic context that is more detailed than an HTTP status code.
| Enum Member | Description | Typical HTTP Status |
|---|---|---|
Success |
The operation was successful. | 200 OK |
Validation |
The request failed due to invalid input data. | 400 Bad Request |
Problem |
An unexpected problem occurred, often used for RFC 7807 problem details. | 500 Internal Server |
NotFound |
The requested resource was not found. | 404 Not Found |
Conflict |
The request conflicts with the current state of the resource. | 409 Conflict |
Unauthorized |
The request requires user authentication. | 401 Unauthorized |
Error |
A general, non-specific error occurred during the operation. | 500 Internal Server |
BadRequest |
The request was malformed or could not be processed for reasons other than validation. | 400 Bad Request |
Example JSON Response
{
"responseCode": 404,
"responseType": "NotFound", // From the ResponseType enum
"responseMessage": "Product with value '99' not found."
}
🚀 Usage Examples
Here’s how you can use these constants within an ASP.NET Core controller to create clean and consistent API endpoints.
using Microsoft.AspNetCore.Mvc;
using RA.Utilities.Core.Constants; // Import the constants
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
[HttpGet("{id}")]
public IActionResult GetProduct(int id)
{
var product = _productService.GetById(id);
if (product == null)
{
// Use constants for both the status code and the response message
return NotFound(BaseResponseMessages.NotFound);
}
return Ok(product);
}
[HttpPost]
public IActionResult CreateProduct([FromBody] Product newProduct)
{
if (!ModelState.IsValid)
{
// Use constants for a bad request
return BadRequest(BaseResponseMessages.BadRequest);
}
var createdProduct = _productService.Create(newProduct);
// Use constants for a 'Created' response
return StatusCode(BaseResponseCode.Created, createdProduct);
}
}
Additional documentation
For more information on how this package fits into the larger RA.Utilities ecosystem, please see the main repository documentation.
Contributing
Contributions are welcome! If you have a suggestion or find a bug, please open an issue to discuss it.
Pull Request Process
- Fork the Repository: Start by forking the RA.Utilities repository.
- Create a Branch: Create a new branch for your feature or bug fix from the
mainbranch. Please use a descriptive name (e.g.,feature/add-result-extensionsorfix/readme-typo). - Make Your Changes: Write your code, ensuring it adheres to the existing coding style. Add or update XML documentation for any new public APIs.
- Update README: If you are adding new functionality, please update the
README.mdfile accordingly. - Submit a Pull Request: Push your branch to your fork and open a pull request to the
mainbranch of the original repository. Provide a clear description of the changes you have made.
Coding Standards
- Follow the existing coding style and conventions used in the project.
- Ensure all public members are documented with clear XML comments.
- Keep changes focused. A pull request should address a single feature or bug.
Thank you for contributing!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on RA.Utilities.Core.Constants:
| Package | Downloads |
|---|---|
|
RA.Utilities.Api.Middlewares
RA.Utilities.Api.Middlewares provides a simple and efficient ASP.NET Core middleware for logging HTTP request and response details. It's designed to be easy to integrate, configurable, and performant, using Microsoft.IO.RecyclableMemoryStream to minimize memory allocations and improve application performance. |
|
|
RA.Utilities.Core.Exceptions
Provides a set of standardized, semantic exceptions for use in the RA.Utilities ecosystem. These exceptions, such as NotFoundException, ConflictException, and BadRequestException, allow for clear, intent-driven error handling in business logic and can be easily mapped to consistent API responses by middleware. |
|
|
RA.Utilities.Api.Results
Provides a standardized set of models for creating consistent API responses. This package includes generic wrappers for success, error, and validation failure scenarios, helping to streamline API development and improve client-side handling. |
|
|
RA.Utilities.Integrations
A utility library to simplify and standardize HTTP client calls in .NET applications. It builds upon `IHttpClientFactory` to provide a structured way to configure and use typed HTTP clients for various integrations. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.100-rc.2 | 122 | 11/1/2025 |
| 10.0.0 | 284 | 11/23/2025 |
| 10.0.0-rc.2 | 162 | 10/27/2025 |