Skip to content

ravarador/Blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog2

ASP.NET Core 8 MVC blog with Identity, EF Core, SQL Server, Bootstrap 5, Markdig, and HtmlSanitizer.

Features

  • Posts — Create, edit, delete; Markdown content; optional excerpt, cover image; draft/publish
  • Comments — Add, edit, delete (owner only); shown on each post
  • Auth — Email/password registration + Google OAuth; DisplayName for authors
  • Slug-based URLs — Unique, SEO-friendly URLs for posts
  • Reading time — Estimated from word count (200 wpm)
  • Pagination — 10 posts per page on home
  • Markdown — Markdig for rendering; HtmlSanitizer for safe HTML output

Tech Stack

Component Technology
Framework ASP.NET Core 8 MVC
Data Entity Framework Core 8, SQL Server
Auth ASP.NET Core Identity (email/password, Google OAuth)
UI Bootstrap 5.3 (CDN)
Markdown Markdig
HTML sanitization HtmlSanitizer (Ganss.Xss)

Prerequisites

  • .NET 8 SDK
  • SQL Server or LocalDB

Setup

  1. Connection string
    Set ConnectionStrings:DefaultConnection in Blog2/appsettings.json or User Secrets. Example:

    "ConnectionStrings": {
      "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=Blog2;Trusted_Connection=True;MultipleActiveResultSets=true"
    }
  2. Database
    In Development the app applies migrations on startup. Otherwise:

    cd Blog2
    dotnet ef database update
  3. Google OAuth (optional)
    Set Authentication:Google:ClientId and Authentication:Google:ClientSecret in appsettings.json or User Secrets. If unset or using placeholder YOUR_GOOGLE_CLIENT_ID, Google sign-in is not registered.

  4. Run

    cd Blog2
    dotnet run

    Open http://localhost:5000

Project Structure

Blog2/
├── Blog2/                 # Main web project
│   ├── Controllers/       # Home, Account, Post, Comment
│   ├── Data/              # ApplicationDbContext
│   ├── Extensions/        # IdentityExtensions
│   ├── Migrations/        # EF Core migrations
│   ├── Models/            # Post, Comment, ApplicationUser
│   ├── Services/          # PostService, CommentService, SlugService, MarkdownService
│   ├── ViewModels/        # View models for views
│   ├── Views/             # Razor views
│   └── wwwroot/css/       # site.css (custom styles)
├── Blog2.sln
└── README.md

Routes

Method Route Description
GET / Published posts (paginated, ?page=)
GET /blog/{slug} Single post and comments
GET /login, POST /login Sign in (email/password)
POST /logout Sign out
GET /register, POST /register Register
GET, POST /external-login External auth (provider=Google)
GET /external-login-callback OAuth callback
GET /post/create, POST /post/create New post (auth)
GET /post/edit/{id}, POST /post/edit/{id} Edit post (owner only)
POST /post/delete/{id} Delete post (owner only)
POST /comment/add Add comment (auth)
POST /comment/edit/{id} Edit comment (owner only)
POST /comment/delete/{id} Delete comment (owner only)
GET /Home/Error Error page (non-dev)

About

ASP.NET Core 8 MVC blog with Identity, EF Core, SQL Server, Bootstrap 5, Markdig, and HtmlSanitizer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors