A complete online shopping platform for fashion enthusiasts, showcasing the latest trends in women's and men's clothing. Built with ASP.NET and C# for beginners to learn web development fundamentals.
- Overview
- Features
- Tech Stack
- Prerequisites
- Installation
- Database Setup
- Configuration
- Project Structure
- Usage Guide
- Screenshots
- Learning Resources
- Contributing
- License
This e-commerce web application is designed as a beginner-friendly project to help developers learn ASP.NET web forms, C# programming, and SQL Server database integration. The platform provides a complete online shopping experience with product browsing, cart management, user authentication, and order processing.
- Students learning ASP.NET and web development
- Beginners wanting hands-on experience with C#
- Developers exploring e-commerce fundamentals
- Teaching web application architecture
- ASP.NET Web Forms architecture
- Master Pages for consistent layouts
- C# code-behind implementation
- SQL Server database design and integration
- Session management and authentication
- Shopping cart functionality
- Admin panel development
- CRUD operations (Create, Read, Update, Delete)
- Home Page - Featured products and latest collections
- Category Pages - Browse products by category
- Product Details - Detailed product information with images
- Search Functionality - Find products quickly
- Responsive Catalog - Grid and list views
- Shopping Cart - Add/remove items, update quantities
- Cart Summary - Real-time price calculation
- Wishlist - Save favorite items for later
- Product Reviews - Customer ratings and feedback
- Stock Availability - Real-time inventory status
- User Registration - Create new customer accounts
- Login/Logout - Secure authentication system
- Profile Management - Update personal information
- Order History - View past orders and status
- Address Book - Save multiple shipping addresses
- Secure Checkout - Multi-step checkout flow
- Order Summary - Review before purchase
- Order Confirmation - Email notifications
- Payment Integration Ready - Placeholder for payment gateways
- Add Products - Create new product listings
- Edit Products - Update product information
- Delete Products - Remove discontinued items
- Product Categories - Organize products hierarchically
- Image Upload - Product photo management
- Inventory Control - Stock level management
- View Orders - Complete order dashboard
- Order Status - Update order processing stages
- Order Details - Customer and product information
- Order Search - Filter by date, status, customer
- Print Invoices - Generate order receipts
- Customer List - View all registered users
- User Details - Customer information and order history
- Account Status - Enable/disable accounts
- Admin Accounts - Manage administrative users
- About Us Page - Company information
- Contact Us - Inquiry form and contact details
- Static Pages - Manage informational content
- Banner Management - Homepage promotional slides
- Framework: ASP.NET Web Forms (.NET Framework 4.5+)
- Language: C# 6.0+
- Database: Microsoft SQL Server 2014+
- ORM: ADO.NET (SqlClient)
- Server: IIS (Internet Information Services)
- Markup: HTML5, ASPX
- Styling: CSS3, Bootstrap 3/4
- Scripting: JavaScript, jQuery
- UI Components: ASP.NET Server Controls
- Icons: Font Awesome
- IDE: Visual Studio 2015/2017/2019/2022
- Database Tool: SQL Server Management Studio (SSMS)
- Version Control: Git
- Browser DevTools: Chrome/Firefox Developer Tools
Before you begin, ensure you have the following installed:
| Software | Version | Download Link |
|---|---|---|
| Visual Studio | 2015 or later | Download |
| SQL Server | 2014 or later | Download |
| SSMS | Latest | Download |
| .NET Framework | 4.5 or later | Included with Visual Studio |
| IIS | 7.0+ | Windows Feature |
- OS: Windows 7/8/10/11 or Windows Server
- RAM: 4GB minimum (8GB recommended)
- Storage: 2GB free space
- Browser: Chrome, Firefox, Edge, or Safari (latest version)
git clone https://github.com/touficSl/ecommerce.git
cd ecommerce- Launch Visual Studio
- Click File β Open β Project/Solution
- Navigate to the cloned folder
- Select the
.slnfile (if present) or open as a Web Site - Visual Studio will load all project files
# In Visual Studio Package Manager Console
Update-Package -ReinstallOr:
- Right-click on Solution in Solution Explorer
- Select Restore NuGet Packages
Open SQL Server Management Studio (SSMS) and execute:
CREATE DATABASE EcommerceDB;
GO
USE EcommerceDB;
GO-- Users Table
CREATE TABLE Users (
UserID INT PRIMARY KEY IDENTITY(1,1),
FullName NVARCHAR(100) NOT NULL,
Email NVARCHAR(100) UNIQUE NOT NULL,
Password NVARCHAR(255) NOT NULL,
Phone NVARCHAR(20),
Address NVARCHAR(500),
City NVARCHAR(50),
PostalCode NVARCHAR(10),
Country NVARCHAR(50),
IsAdmin BIT DEFAULT 0,
CreatedDate DATETIME DEFAULT GETDATE(),
IsActive BIT DEFAULT 1
);
-- Categories Table
CREATE TABLE Categories (
CategoryID INT PRIMARY KEY IDENTITY(1,1),
CategoryName NVARCHAR(100) NOT NULL,
Description NVARCHAR(500),
ImageURL NVARCHAR(255),
IsActive BIT DEFAULT 1,
CreatedDate DATETIME DEFAULT GETDATE()
);
-- Products Table
CREATE TABLE Products (
ProductID INT PRIMARY KEY IDENTITY(1,1),
ProductName NVARCHAR(200) NOT NULL,
Description NVARCHAR(MAX),
CategoryID INT FOREIGN KEY REFERENCES Categories(CategoryID),
Price DECIMAL(10,2) NOT NULL,
DiscountPrice DECIMAL(10,2),
StockQuantity INT DEFAULT 0,
ImageURL NVARCHAR(255),
Brand NVARCHAR(100),
Gender NVARCHAR(10), -- 'Men', 'Women', 'Unisex'
Sizes NVARCHAR(100), -- 'S,M,L,XL'
Colors NVARCHAR(100), -- 'Red,Blue,Green'
IsFeatured BIT DEFAULT 0,
IsActive BIT DEFAULT 1,
CreatedDate DATETIME DEFAULT GETDATE()
);
-- Shopping Cart Table
CREATE TABLE ShoppingCart (
CartID INT PRIMARY KEY IDENTITY(1,1),
UserID INT FOREIGN KEY REFERENCES Users(UserID),
ProductID INT FOREIGN KEY REFERENCES Products(ProductID),
Quantity INT NOT NULL DEFAULT 1,
Size NVARCHAR(10),
Color NVARCHAR(20),
AddedDate DATETIME DEFAULT GETDATE()
);
-- Orders Table
CREATE TABLE Orders (
OrderID INT PRIMARY KEY IDENTITY(1,1),
UserID INT FOREIGN KEY REFERENCES Users(UserID),
OrderDate DATETIME DEFAULT GETDATE(),
TotalAmount DECIMAL(10,2) NOT NULL,
OrderStatus NVARCHAR(50) DEFAULT 'Pending', -- Pending, Processing, Shipped, Delivered, Cancelled
ShippingAddress NVARCHAR(500),
ShippingCity NVARCHAR(50),
ShippingPostalCode NVARCHAR(10),
ShippingCountry NVARCHAR(50),
PaymentMethod NVARCHAR(50),
PaymentStatus NVARCHAR(50) DEFAULT 'Pending',
TrackingNumber NVARCHAR(100),
Notes NVARCHAR(1000)
);
-- Order Details Table
CREATE TABLE OrderDetails (
OrderDetailID INT PRIMARY KEY IDENTITY(1,1),
OrderID INT FOREIGN KEY REFERENCES Orders(OrderID),
ProductID INT FOREIGN KEY REFERENCES Products(ProductID),
Quantity INT NOT NULL,
Price DECIMAL(10,2) NOT NULL,
Size NVARCHAR(10),
Color NVARCHAR(20),
Subtotal AS (Quantity * Price) PERSISTED
);
-- Contact Messages Table
CREATE TABLE ContactMessages (
MessageID INT PRIMARY KEY IDENTITY(1,1),
Name NVARCHAR(100) NOT NULL,
Email NVARCHAR(100) NOT NULL,
Subject NVARCHAR(200),
Message NVARCHAR(MAX) NOT NULL,
IsRead BIT DEFAULT 0,
ReceivedDate DATETIME DEFAULT GETDATE()
);-- Sample Categories
INSERT INTO Categories (CategoryName, Description) VALUES
('Women''s Clothing', 'Latest fashion for women'),
('Men''s Clothing', 'Stylish outfits for men'),
('Accessories', 'Fashion accessories'),
('Shoes', 'Footwear collection');
-- Sample Products
INSERT INTO Products (ProductName, Description, CategoryID, Price, StockQuantity, Gender) VALUES
('Summer Dress', 'Elegant floral summer dress', 1, 49.99, 25, 'Women'),
('Casual Shirt', 'Cotton casual shirt for men', 2, 29.99, 40, 'Men'),
('Denim Jeans', 'Classic blue denim jeans', 2, 59.99, 30, 'Unisex'),
('Leather Handbag', 'Premium leather handbag', 3, 89.99, 15, 'Women'),
('Running Shoes', 'Comfortable running shoes', 4, 79.99, 50, 'Unisex');
-- Sample Admin User (password: admin123 - should be hashed in production)
INSERT INTO Users (FullName, Email, Password, IsAdmin) VALUES
('Admin User', 'admin@ecommerce.com', 'admin123', 1);
-- Sample Customer
INSERT INTO Users (FullName, Email, Password, Phone, Address, City) VALUES
('John Doe', 'john@example.com', 'password123', '1234567890', '123 Main St', 'New York');If you have a .mdf database file:
- Open SSMS
- Right-click Databases β Attach
- Click Add β Browse to your
.mdffile - Click OK
Open web.config and update the connection string:
<configuration>
<connectionStrings>
<add name="EcommerceConnectionString"
connectionString="Data Source=YOUR_SERVER_NAME;Initial Catalog=EcommerceDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
<!-- OR with SQL Authentication -->
<add name="EcommerceConnectionString"
connectionString="Data Source=YOUR_SERVER_NAME;Initial Catalog=EcommerceDB;User ID=YOUR_USERNAME;Password=YOUR_PASSWORD"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>Finding Your Server Name:
- Open SSMS
- Server name appears in the connection dialog
- Usually:
localhost,.\SQLEXPRESS, or(localdb)\MSSQLLocalDB
For local development, Visual Studio's built-in IIS Express is sufficient. For production:
- Open IIS Manager
- Right-click Sites β Add Website
- Set:
- Site name: Ecommerce
- Physical path: Your project folder
- Port: 80 or 8080
- Click OK
Additional settings in web.config:
<appSettings>
<!-- Email Configuration (for order confirmations) -->
<add key="SMTPServer" value="smtp.gmail.com" />
<add key="SMTPPort" value="587" />
<add key="SMTPUsername" value="your-email@gmail.com" />
<add key="SMTPPassword" value="your-password" />
<!-- File Upload Settings -->
<add key="ProductImagePath" value="~/Images/Products/" />
<add key="MaxFileSize" value="5242880" /> <!-- 5MB in bytes -->
<!-- Pagination -->
<add key="ProductsPerPage" value="12" />
</appSettings>ecommerce/
βββ π Images/ # Product and category images
β βββ Products/
β βββ Categories/
β βββ Banners/
βββ π CSS/ # Stylesheets
β βββ style.css
β βββ admin.css
βββ π JS/ # JavaScript files
β βββ script.js
βββ π App_Code/ # C# class files (optional)
β βββ DatabaseHelper.cs
β βββ Utilities.cs
βββ π Main.master # Master page template
βββ π Main.master.cs # Master page code-behind
β
βββ π Customer Pages
β βββ π Home.aspx # Homepage with featured products
β βββ π Home.aspx.cs
β βββ π Category.aspx # Product listing by category
β βββ π Category.aspx.cs
β βββ π Basket.aspx # Shopping cart
β βββ π Basket.aspx.cs
β βββ π Orders.aspx # Order history
β βββ π Orders.aspx.cs
β βββ π Register.aspx # User registration
β βββ π Register.aspx.cs
β βββ π AboutUs.aspx # About page
β βββ π AboutUs.aspx.cs
β βββ π ContactUs.aspx # Contact form
β βββ π ContactUs.aspx.cs
β
βββ π¨βπΌ Admin Pages
β βββ π Admin.aspx # Admin dashboard
β βββ π Admin.aspx.cs
β βββ π SignAdmin.aspx # Admin login
β βββ π SignAdmin.aspx.cs
β
βββ π web.config # Application configuration
Homepage:
http://localhost:port/Home.aspx
- View featured products
- Browse by category
- See latest arrivals
Category Page:
http://localhost:port/Category.aspx?id=1
- Filter products by category
- Sort by price, name, or date
- View product details
Adding to Cart:
- Click on a product
- Select size and color
- Click "Add to Cart"
- View cart icon for item count
Managing Cart:
http://localhost:port/Basket.aspx
- Update quantities
- Remove items
- View total price
- Proceed to checkout
Registration:
http://localhost:port/Register.aspx
Required fields:
- Full Name
- Email Address
- Password
- Phone Number
- Shipping Address
Login:
- Use registered email and password
- Access order history
- Manage profile
Checkout Process:
- Review items in cart
- Confirm shipping address
- Select payment method
- Review order summary
- Place order
- Receive order confirmation
Order History:
http://localhost:port/Orders.aspx
- View all past orders
- Check order status
- Download invoices
http://localhost:port/SignAdmin.aspx
Default Credentials:
- Email:
admin@ecommerce.com - Password:
admin123
http://localhost:port/Admin.aspx
Dashboard Features:
- Total sales statistics
- Recent orders
- Low stock alerts
- Customer count
- Revenue reports
Add New Product:
// Code example in Admin.aspx.cs
protected void btnAddProduct_Click(object sender, EventArgs e)
{
string productName = txtProductName.Text;
decimal price = decimal.Parse(txtPrice.Text);
int categoryID = int.Parse(ddlCategory.SelectedValue);
// Save product to database
SaveProduct(productName, price, categoryID);
}Upload Product Image:
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fileUpload.HasFile)
{
string fileName = Path.GetFileName(fileUpload.FileName);
string filePath = Server.MapPath("~/Images/Products/" + fileName);
fileUpload.SaveAs(filePath);
}
}View Orders:
- Filter by status (Pending, Processing, Shipped, Delivered)
- Search by order ID or customer name
- Update order status
- Print invoices
Update Order Status:
protected void btnUpdateStatus_Click(object sender, EventArgs e)
{
int orderID = int.Parse(txtOrderID.Text);
string newStatus = ddlStatus.SelectedValue;
// Update in database
UpdateOrderStatus(orderID, newStatus);
}This is a learning project and includes basic security implementations. For production use, implement:
Current Implementation:
// Basic password storage (NOT SECURE for production)
string password = txtPassword.Text;Recommended for Production:
using System.Security.Cryptography;
using System.Text;
public static string HashPassword(string password)
{
using (SHA256 sha256Hash = SHA256.Create())
{
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(password));
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
return builder.ToString();
}
}Always use parameterized queries:
// β BAD - Vulnerable to SQL Injection
string query = "SELECT * FROM Users WHERE Email = '" + email + "'";
// β
GOOD - Safe parameterized query
string query = "SELECT * FROM Users WHERE Email = @Email";
SqlCommand cmd = new SqlCommand(query, connection);
cmd.Parameters.AddWithValue("@Email", email);// Store user info in session after login
Session["UserID"] = userID;
Session["IsAdmin"] = isAdmin;
Session.Timeout = 30; // 30 minutes
// Check authentication
if (Session["UserID"] == null)
{
Response.Redirect("Login.aspx");
}// Server-side validation
protected void ValidateInput()
{
if (string.IsNullOrWhiteSpace(txtEmail.Text))
{
lblError.Text = "Email is required";
return;
}
if (!IsValidEmail(txtEmail.Text))
{
lblError.Text = "Invalid email format";
return;
}
}
Featured products and category navigation
Sales statistics and quick actions
ASP.NET Web Forms:
C# Programming:
SQL Server:
Database Connection Pattern:
using System.Data.SqlClient;
using System.Configuration;
public class DatabaseHelper
{
private string connectionString = ConfigurationManager.ConnectionStrings["EcommerceConnectionString"].ConnectionString;
public SqlConnection GetConnection()
{
return new SqlConnection(connectionString);
}
public DataTable ExecuteQuery(string query, SqlParameter[] parameters = null)
{
DataTable dt = new DataTable();
using (SqlConnection conn = GetConnection())
{
using (SqlCommand cmd = new SqlCommand(query, conn))
{
if (parameters != null)
{
cmd.Parameters.AddRange(parameters);
}
conn.Open();
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(dt);
}
}
return dt;
}
}- Add product search functionality
- Implement pagination for product listings
- Create a wishlist feature
- Add product rating and review system
- Implement email notifications
- Integrate payment gateway (PayPal, Stripe)
- Add product comparison feature
- Implement advanced filtering (price range, brand)
- Create promotional code system
- Add social media login (Facebook, Google)
- Migrate to ASP.NET MVC or ASP.NET Core
- Implement RESTful API
- Add real-time inventory management
- Create mobile app using Xamarin
- Implement recommendation engine
- Add multi-language support
- Integrate with shipping providers
- Session timeout may clear shopping cart
- Image upload doesn't validate file types thoroughly
- No email verification for registration
- Limited error handling in some pages
- Admin dashboard statistics need caching
Workarounds available in Issues section
Contributions are welcome! This project is designed for learning, so improvements and educational enhancements are especially appreciated.
-
Fork the repository
git clone https://github.com/YOUR_USERNAME/ecommerce.git
-
Create a feature branch
git checkout -b feature/AmazingFeature
-
Make your changes
- Add features
- Fix bugs
- Improve documentation
- Add comments for learning purposes
-
Commit your changes
git commit -m 'Add some AmazingFeature' -
Push to the branch
git push origin feature/AmazingFeature
-
Open a Pull Request
- Write clear, commented code for educational purposes
- Update README if you add new features
- Test all changes locally
- Follow C# naming conventions
- Add inline comments explaining complex logic
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Toufic Sleiman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.
Toufic Sleiman
- π GitHub: @touficSl
- πΌ LinkedIn: Toufic Sleiman
- π¦ Twitter: @sleiman_toufic
- π» Freelancer: TouficSl
- Thanks to the ASP.NET community for excellent documentation
- Bootstrap team for the responsive framework
- Font Awesome for icon library
- All contributors and students learning from this project
Found a bug?
- Open an Issue
- Provide detailed steps to reproduce
Have a question?
- Check existing Issues
- Ask in Discussions
Need custom development?
- Contact me via LinkedIn
- Available for freelance projects
-
Publish from Visual Studio:
- Right-click project β Publish
- Select Folder β Choose output location
- Click Publish
-
Configure IIS:
- Create new website in IIS
- Point to published folder
- Set application pool to .NET 4.x
- Configure database connection string
-
Security Checklist:
- Change default admin credentials
- Use HTTPS/SSL certificate
- Hash passwords properly
- Sanitize all user inputs
- Enable error logging
- Set up regular database backups
Happy Coding! π
This project is perfect for learning ASP.NET fundamentals. Feel free to customize and extend it for your needs!
Made with β€οΈ by Toufic Sleiman | Last updated: December 2024




