Skip to content

Commit cf6fbf2

Browse files
committed
Readme completed.
1 parent 955e564 commit cf6fbf2

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Project Title
2+
3+
## Introduction
4+
5+
This project is a .NET WebAPI project that demonstrates how to use resources (resx) files to provide messages for validations and errors. The objective is to centralize the error and validation messages in resource files, standardize the messages and making it easier to manage.
6+
7+
## Article
8+
I have written an article explaining the implementation details of this project. You can find the article [here](https://dev.to/jvidaln/standardizing-validation-and-error-messages-using-resource-resx-files-in-net-2c9p "Standardizing validation and error messages using Resource (.resx) files in .NET").
9+
10+
## Getting Started
11+
12+
### Prerequisites
13+
* .NET 7 SDK
14+
* Visual Studio Code (or any other preferred code editor)
15+
16+
### Clone the Repository
17+
18+
Clone this repository to your local machine using the following command:
19+
20+
```
21+
git clone https://github.com/JVidalN/dotnet-standardizing-messages-with-resource-resx-files.git
22+
```
23+
24+
### Build and Run the Project
25+
1. Open the project in Visual Studio Code (or your preferred code editor).
26+
2. Restore the dependencies and build the project:
27+
28+
```
29+
dotnet restore
30+
dotnet build
31+
```
32+
33+
### Run the project:
34+
35+
```
36+
dotnet run
37+
```
38+
39+
The API will start running at **`https://localhost:5001`** (or **`http://localhost:5000`** for HTTP) by default.
40+
41+
### Commands Used To Create The Project
42+
43+
1. Create the .NET solution file using the following command:
44+
`dotnet new sln -n ResourceResx`
45+
46+
2. Create the project:
47+
`dotnet new webapi -n WebApiResource`
48+
49+
3. Add the created project to the solution:
50+
`dotnet sln add WebApiResource/WebApiResource.csproj`
51+
52+
## Resource Files
53+
54+
The project contains two resource files located in the `Resources` folder:
55+
56+
1. **`ErrorMessages.resx`**: Contains error messages with HTTP status codes as keys and corresponding error messages as values. This allows us to easily return standard error messages for specific HTTP status codes.
57+
58+
2. **`ValidationMessages.resx`**: Contains validation messages with keys such as "Required", "Email", "Length", etc., which are used for annotating the model properties in the `User` model.
59+
60+
## How It Works
61+
62+
The project demonstrates how to use the resource files to provide error and validation messages in the API.
63+
64+
To understand in more detail how it works and the idea, read the article I made. Article link in the Article section above.
65+
66+
## Contributing
67+
68+
Contributions to this project are welcome!
69+
If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

0 commit comments

Comments
 (0)