This is my first project using C# and ASP.NET Core. After recently exploring Go and building a project with it, I wanted to continue broadening my skill set by trying something new. My curiosity led me to C# and ASP.NET Core, and this project gave me the chance to dive into both and see how they compare.
Key features and technologies implemented are:
-
JWT Authentication
: Secure user authentication using JSON Web Tokens for session management. -
Middlewares
: Developed custom middleware to verify JWTs, ensuring only authenticated users can access protected routes. -
Password Hashing
: Leveraged bcrypt for secure password storage, ensuring user credentials are safely hashed. -
OTP Verification
: Implemented a robust signup process with One-Time Password (OTP) verification, enhancing user registration security. -
Cloudinary Integration
: Successfully integrated Cloudinary for image uploads, allowing users to manage their profile pictures seamlessly. -
Input Validation
: Incorporated comprehensive input validation to ensure data integrity and prevent malicious input. -
Bloom Filters
: Implemented Bloom filters to efficiently check for existing emails during user registration, optimizing performance for large databases. -
CORS Management
: Configured Cross-Origin Resource Sharing (CORS) to enable secure interactions between the frontend and backend.
-
C# ASP.NET Core
: Used as the main framework for building the backend of the application. It provides a powerful, cross-platform environment for building web APIs and services. -
Entity Framework Core
: The Object-Relational Mapper (ORM) used to manage database operations. It allows developers to work with databases using .NET objects and eliminates the need for most of the data-access code typically required. -
Cloudinary
: Integrated for image management and storage. It provides services such as image uploads, transformations, and optimized delivery, simplifying the handling of media files. -
Docker
: Used to containerize the application, ensuring consistent environments for development, testing, and deployment. Docker simplifies dependency management and allows the app to run seamlessly across different machines.
-
Clone the repository to your local machine:
git clone https://github.com/Sahil2k07/Blog-CSharp.git
-
Move to the project directory:
cd Blog-CSharp
-
Set up all the required env variables by making a
.env
file. A.env.example
file has been given for reference.APP_URL=http://localhost:6000 ALLOWED_ORIGIN=* DATABASE_URL="Host=localhost;Port=5432;Database=database;Username=postgres;Password=password;" # Mailer Details. MAIL_HOST=smtp.gmail.com MAIL_USER= MAIL_PASS= # Cloudinary Details. CLOUD_NAME= API_KEY= API_SECRET= FOLDER_NAME= # Minimum 32 characters or will give error ;) Microsoft Guys want Applications to be Secured JWT_SECRET="Blog-App-C#-secret-for-authenticating-users"
-
Restore all the packages
dotnet restore
-
Install the
ef
package globally to apply migrationsdotnet tool install --global dotnet-ef
-
Apply the Migrations
dotnet ef database update
-
Run the Application
dotnet run
-
Clone the repository to your local machine:
git clone https://github.com/Sahil2k07/Blog-CSharp.git
-
Move to the project directory:
cd Blog-CSharp
-
Set up these env variables by making a
.env
file. A.env.example
file has been given for reference.# Mailer Details. MAIL_HOST=smtp.gmail.com MAIL_USER= MAIL_PASS= # Cloudinary Details. CLOUD_NAME= API_KEY= API_SECRET= FOLDER_NAME=
-
Run the command to start the Docker container:
docker-compose up
or run in background
(detached mode)
docker-compose up -d
-
If you have docker compose plugin, use this command instead:
docker compose up
or run in background
(detached mode)
docker compose up -d
-
Access the project on
http://localhost:5000
of your machine.