Skip to content

DibyaGit/ADO.NET-OnlineShop

Repository files navigation

πŸ›’ ADO.NET OnlineShop

A secure, full-featured ASP.NET Core MVC e-commerce web application built with Entity Framework Core, ASP.NET Core Identity, and classic MVC architecture.

.NET ASP.NET Core MVC Entity Framework Core License


πŸ“‹ Table of Contents


Overview

ADO.NET OnlineShop is a small online shopping platform demonstrating secure web application development practices. It implements user registration/login with ASP.NET Core Identity, role-based authorization, product browsing, order placement, and customer reviews β€” all following the classic MVC (Model-View-Controller) pattern.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   BROWSER                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              CONTROLLERS                         β”‚
β”‚  HomeController  AccountController               β”‚
β”‚  ProductController  AdminController              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              SERVICES                            β”‚
β”‚  IAccountService β†’ AccountService                β”‚
β”‚  (Business Logic Layer)                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              DATA LAYER                          β”‚
β”‚  ApplicationDbContext (EF Core InMemory)         β”‚
β”‚  ASP.NET Core Identity                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

OnlineShop/
β”œβ”€β”€ Controllers/
β”‚   β”œβ”€β”€ HomeController.cs           # Landing page
β”‚   β”œβ”€β”€ AccountController.cs        # Auth (Register/Login/Logout)
β”‚   β”œβ”€β”€ ProductController.cs        # Product CRUD + Orders + Reviews
β”‚   └── AdminController.cs          # Admin dashboard
β”œβ”€β”€ Models/
β”‚   β”œβ”€β”€ ApplicationUser.cs          # Identity user with Role
β”‚   β”œβ”€β”€ Product.cs                  # Product entity
β”‚   β”œβ”€β”€ Order.cs                    # Order entity
β”‚   β”œβ”€β”€ ProductReview.cs            # Review entity
β”‚   β”œβ”€β”€ RegisterViewModel.cs        # Registration form model
β”‚   β”œβ”€β”€ LoginViewModel.cs           # Login form model
β”‚   └── ProductReviewViewModel.cs   # Review form model
β”œβ”€β”€ Data/
β”‚   └── ApplicationDbContext.cs     # EF Core context + seed data
β”œβ”€β”€ Services/
β”‚   β”œβ”€β”€ IAccountService.cs          # Service interface
β”‚   └── AccountService.cs           # Auth business logic
β”œβ”€β”€ Views/
β”‚   β”œβ”€β”€ Home/Index.cshtml           # Public landing page
β”‚   β”œβ”€β”€ Account/
β”‚   β”‚   β”œβ”€β”€ Register.cshtml         # Registration form
β”‚   β”‚   β”œβ”€β”€ Login.cshtml            # Login form
β”‚   β”‚   └── AccessDenied.cshtml     # 403 page
β”‚   β”œβ”€β”€ Product/
β”‚   β”‚   β”œβ”€β”€ Index.cshtml            # Product catalog
β”‚   β”‚   └── Details.cshtml          # Product detail + reviews
β”‚   β”œβ”€β”€ Admin/Dashboard.cshtml      # Admin panel
β”‚   └── Shared/_Layout.cshtml       # Bootstrap navbar layout
└── Program.cs                      # App configuration & DI

Features

πŸ” Authentication & Authorization

  • ASP.NET Core Identity with Cookie-based authentication
  • Role-based access control (Admin / Customer)
  • [Authorize] and [Authorize(Roles = "Admin")] route protection
  • Automatic redirect to login with ReturnUrl for unauthorized access

πŸ“ User Registration & Login

  • Client-side + Server-side validation on all forms
  • Password complexity enforcement (uppercase, lowercase, digit, special char)
  • Brute-force protection: Account lockout after 5 failed attempts (5-minute lock)
  • Passwords hashed automatically by ASP.NET Core Identity

πŸ›οΈ Product Management

  • Public product catalog with 5 seeded products
  • Product detail pages with stock information
  • Authenticated order placement with stock validation
  • Customer review system (1-5 star rating + comments)

πŸ“Š Admin Dashboard

  • Protected admin panel at /Admin/Dashboard
  • Real-time counts: Total Users, Total Orders, Total Products

πŸ›‘οΈ Security

  • SQL Injection Prevention: 100% EF Core LINQ queries β€” zero raw SQL
  • XSS Prevention: Razor auto-encodes all output; @Html.AntiForgeryToken() on all POST forms
  • CSRF Protection: All state-changing requests require anti-forgery tokens
  • Input Validation: Both HTML5 client-side and Data Annotation server-side validation
  • Secure Logout: SignOutAsync() clears authentication cookies completely

Security Implementation

Threat Mitigation
SQL Injection EF Core LINQ exclusively β€” no FromSqlRaw, no string concatenation
XSS (Cross-Site Scripting) Razor auto HTML-encoding; no @Html.Raw() on user content
CSRF (Cross-Site Request Forgery) [ValidateAntiForgeryToken] + @Html.AntiForgeryToken() on all POST forms
Brute Force Identity lockout: 5 failed attempts β†’ 5-minute lockout
Password Storage ASP.NET Core Identity PBKDF2 hashing (never custom)
Unauthorized Access Role-based [Authorize] attributes; AccessDenied handling

Getting Started

Prerequisites

Installation

# Clone the repository
git clone https://github.com/DibyaGit/ADO.NET-OnlineShop.git
cd ADO.NET-OnlineShop

# Restore dependencies
dotnet restore

# Run the application
dotnet run

The application starts at https://localhost:5001 (or the port shown in your terminal).

Build

dotnet build

Default Credentials

Role Email Password
Admin admin@shop.com Admin@123
Customer customer@shop.com Customer@123

New registrations are automatically assigned the Customer role.


Database

This project uses Entity Framework Core InMemory Database β€” no external database setup required. Data is seeded on startup:

Product Price
Wireless Mouse $29.99
Mechanical Keyboard $79.99
USB-C Hub $45.00
Laptop Stand $35.50
Webcam 1080p $59.99

Technologies Used

Technology Purpose
ASP.NET Core 10.0 MVC Web framework
Entity Framework Core ORM / Data access
EF Core InMemory Database provider
ASP.NET Core Identity Authentication & user management
Bootstrap 5 UI styling
jQuery Validation Client-side form validation
Razor View engine

License

MIT Β© DibyaGit

About

A secure ASP.NET Core MVC e-commerce web application with Identity authentication, role-based authorization, EF Core InMemory database, and comprehensive input validation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors