Skip to content
MohammadHasanpPublic

About

A modern web-based blog platform designed for publishing, managing, and exploring high-quality content with a clean and user-friendly experience.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Blog.Web

A full-featured, RTL Persian blog engine built with ASP.NET Core 5, Entity Framework Core, and SQL Server β€” featuring a clean layered architecture, a public blog website, and a full admin panel for content management.

.NET C# ASP.NET Core EF Core SQL Server AdminLTE CKEditor UI License


πŸ“– Overview

Blog.Web is a complete content-management solution for running a Persian (Farsi) blog:

  • A public website (Razor Pages) where visitors browse posts by category, read articles, search, and leave comments β€” with a fully RTL UI based on the Mag template and the IRANSans font.
  • An admin panel (MVC Area) based on AdminLTE 3 where administrators manage posts, categories, and users, with CKEditor 4 for rich-text authoring and image uploads.
  • A 3-layer architecture that cleanly separates data access, business logic, and presentation.
Author Mohammad Hasan Pirayandeh (@MohammadHasanp)
Stack C# / .NET 5, ASP.NET Core (MVC + Razor Pages), EF Core, SQL Server
Language of UI Persian (RTL)
Database SQL Server (code-first with migrations)

✨ Features

Public site

  • 🏠 Home page β€” latest posts, special/featured posts, popular posts (loaded via AJAX), and a category navigator with post counts
  • πŸ“„ Post pages with SEO-friendly slug URLs (/Post/{slug}), visit counters, related posts, and a comment form
  • πŸ”Ž Search with filtering by keyword and category, plus pagination
  • πŸ“š Nested categories (main categories + subcategories) with SEO meta tags & meta description
  • πŸ‘€ User registration & login (cookie authentication, 30-day persistent session)
  • πŸ›‘ Custom error pages (404 / 500)

Admin panel (/Admin)

  • πŸ“Š Dashboard (AdminLTE 3, RTL)
  • ✍️ Posts management β€” create/edit/delete with CKEditor 4 rich-text editor, cover image & in-content image upload, slug uniqueness check, special-post flag
  • πŸ—‚ Categories management β€” hierarchical (parent/child), SEO fields
  • πŸ‘₯ Users management β€” search, pagination, edit user info & roles (Admin / Writer / User), modal-based editing
  • πŸ” Role-based authorization β€” the whole admin area is protected by an adminPolicy requiring the Admin role

Architecture highlights

  • Clean 3-layer design with dependency injection everywhere
  • Service interfaces + implementations (IXxxService β†’ XxxService)
  • DTO layer for all inputs/outputs, with dedicated mapper classes
  • OperationResult pattern for consistent success/error results
  • Reusable utilities: slug generator, MD5 password encoder, image validation, pagination helper, date helpers, file manager for uploads
  • Soft-delete support (IsDelete) and audit timestamp (Time) built into BaseEntity

🧱 Architecture

flowchart TD
    A[Blog.Web β€” Presentation<br/>Razor Pages + MVC Admin Area] --> B[Blog.CoreLayer β€” Business Logic<br/>Services Β· DTOs Β· Mappers Β· Utilities]
    B --> C[Blog.DataLayer β€” Data Access<br/>BlogContext Β· Entities Β· Migrations]
    C --> D[(SQL Server β€” Blog_db)]
Loading
Layer Project Responsibility
Presentation Blog.Web Public Razor Pages site + /Admin MVC area, authentication & authorization, static assets (wwwroot)
Business Logic Blog.CoreLayer Services (Posts, Categories, Users, Comments, MainPage, FileManager), DTOs, mappers, cross-cutting utilities
Data Access Blog.DataLayer EF Core BlogContext, entities, code-first migrations, SQL Server configuration

πŸ›  Tech Stack

Technology Usage
C# / .NET 5 Target framework (net5.0)
ASP.NET Core MVC Admin panel (Areas, controllers, views)
Razor Pages Public website pages
Entity Framework Core ORM, code-first migrations
SQL Server Database (Blog_db)
Cookie Authentication Login / registration, role-based policies
AdminLTE 3 (RTL) Admin panel template
Mag template + IRANSans Public RTL theme
CKEditor 4 Rich-text editor with image upload
Bootstrap Β· jQuery Β· Chart.js Front-end assets

πŸ“ Project Structure

Blog.Web/
β”œβ”€β”€ Blog.sln                     # Solution (3 projects)
β”‚
β”œβ”€β”€ Blog.Web/                    # πŸ–₯ Presentation layer (ASP.NET Core 5)
β”‚   β”œβ”€β”€ Program.cs / Startup.cs  #   Host, DI registrations, auth & routing config
β”‚   β”œβ”€β”€ Pages/                   #   Public site (Razor Pages)
β”‚   β”‚   β”œβ”€β”€ Index.cshtml         #     Home page (latest, special & popular posts)
β”‚   β”‚   β”œβ”€β”€ Post.cshtml          #     Post detail + comments (slug-routed)
β”‚   β”‚   β”œβ”€β”€ Search.cshtml        #     Search by keyword & category
β”‚   β”‚   β”œβ”€β”€ Auth/                #     Login / Register / Logout
β”‚   β”‚   └── Shared/              #     Layouts, header, footer, partial views
β”‚   β”œβ”€β”€ Areas/Admin/             #   Admin panel (MVC area, Admin policy)
β”‚   β”‚   β”œβ”€β”€ Controllers/         #     Home, Post, Category, User, Upload
β”‚   β”‚   β”œβ”€β”€ Models/              #     View models (create/edit)
β”‚   β”‚   └── Views/               #     AdminLTE views + editor templates
β”‚   β”œβ”€β”€ Controllers/             #   ErrorHandler (custom 404 / 500 pages)
β”‚   β”œβ”€β”€ TagHelpers/              #   Custom OpenModal tag helper
β”‚   β”œβ”€β”€ appsettings.json         #   Connection string & logging config
β”‚   └── wwwroot/                 #   Static assets (css, js, images, CKEditor, AdminLTE)
β”‚
β”œβ”€β”€ Blog.CoreLayer/              # 🧠 Business logic layer (class library)
β”‚   β”œβ”€β”€ Services/
β”‚   β”‚   β”œβ”€β”€ Posts/               #   Post CRUD, filtering, slugs, visits, related posts
β”‚   β”‚   β”œβ”€β”€ Categoryes/          #   Category CRUD & slugs
β”‚   β”‚   β”œβ”€β”€ Users/               #   Register, login, edit, filtering
β”‚   β”‚   β”œβ”€β”€ Comment/             #   Comments CRUD
β”‚   β”‚   β”œβ”€β”€ Mainpage/            #   Aggregated home-page data
β”‚   β”‚   └── FileManager/         #   Save/delete files & images on disk
β”‚   β”œβ”€β”€ Dtos/                    #   Data-transfer objects per feature
β”‚   β”œβ”€β”€ Mpperes/                 #   Entity ↔ DTO mappers
β”‚   └── Utilities/               #   OperationResult, pagination, slug & date
β”‚                               #   helpers, MD5 encoder, image validation
β”‚
β”œβ”€β”€ Blog.DataLayer/              # πŸ—„ Data access layer (class library)
β”‚   β”œβ”€β”€ Context/BlogContext.cs   #   EF Core DbContext (Posts, Users, Categories, Comments)
β”‚   β”œβ”€β”€ Entyties/                #   User, Post, Category, PostComment, BaseEntity
β”‚   └── Migrations/              #   Code-first EF migrations
β”‚
β”œβ”€β”€ Mag/                         # 🎨 Original "Mag" HTML template (public theme source)
└── admin/                       # 🎨 Original AdminLTE HTML template (admin theme source)

ℹ️ Mag/ and admin/ hold the original static HTML templates the site themes were built from; the compiled assets actually used by the app live under Blog.Web/wwwroot/.


πŸ—ƒ Data Model

Entity Description
User Username, full name, password (MD5-hashed), UserRole enum (Admin / Writer / User)
Post Title, slug, description (HTML), cover image, visit counter, IsSpecial flag, links to author, category and optional subcategory
Category Title, slug, SEO meta tag & description, optional ParentId (self-referencing hierarchy)
PostComment Comment text, linked to a user and a post
BaseEntity Shared base: primary key, creation Time, IsDelete soft-delete flag

All foreign keys are configured with cascade delete.


πŸš€ Getting Started

Prerequisites

  • .NET 5 SDK
  • SQL Server (LocalDB or a full instance)
  • (Optional) Visual Studio 2019/2022 or VS Code

Setup

# 1. Clone the repository
git clone https://github.com/MohammadHasanp/Blog.Web.git
cd Blog.Web

# 2. Check the connection string (Blog.Web/appsettings.json β†’ "Defualt")
#    Default: Server=.;Database=Blog_db;Integrated Security=true

# 3. Create / update the database from the code-first migrations
dotnet tool install --global dotnet-ef        # if not installed
dotnet ef database update --project Blog.DataLayer --startup-project Blog.Web

# 4. Run the app
dotnet run --project Blog.Web

Then browse to https://localhost:5001 (public site) or /Admin (admin panel).

πŸ”‘ Getting admin access

There is no seeded admin account. To gain access to the admin panel:

  1. Register a normal account on the site at /Auth/Register.
  2. Promote it to the Admin role in the database:
UPDATE Users SET Role = 0 /* Admin */ WHERE UserName = 'your_username';
  1. Log in again and open /Admin.

βš™οΈ Configuration

Blog.Web/appsettings.json:

"ConnectionStrings": {
  "Defualt": "Server=.;Database=Blog_db;Integrated Security=true;MultipleActiveResultSets=true"
}

Uploaded post images are stored under wwwroot/images/posts (content images under .../posts/content) β€” see Directories.cs in the CoreLayer.


πŸ—Ί Roadmap / Ideas

  • ⬆️ Upgrade from .NET 5 (EOL) to a supported .NET version
  • πŸ”’ Replace MD5 password hashing with a modern KDF (PBKDF2 / BCrypt)
  • πŸ§ͺ Add unit/integration tests
  • 🌐 Multi-language support (currently Persian-only)
  • πŸ“Š Dashboard statistics widgets with Chart.js

πŸ‘€ Author

Mohammad Hasan Pirayandeh β€” @MohammadHasanp

πŸ“§ PirayandehMohammadHasan@gmail.com


πŸ™ Acknowledgements


⭐ If you like this project, please consider giving it a star on GitHub! ⭐

About

A modern web-based blog platform designed for publishing, managing, and exploring high-quality content with a clean and user-friendly experience.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages