0% found this document useful (0 votes)
8 views83 pages

ASP.NET Blog and Comment Management

The document outlines the implementation of a blogging application using ASP.NET Core, featuring controllers for managing blogs and comments, as well as user authentication and role management. It includes methods for creating, editing, deleting, and viewing blog posts and comments, with administrative controls for content management. Additionally, it describes the application database context and seeding data for initial setup, along with models for users, blog posts, comments, and error handling.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views83 pages

ASP.NET Blog and Comment Management

The document outlines the implementation of a blogging application using ASP.NET Core, featuring controllers for managing blogs and comments, as well as user authentication and role management. It includes methods for creating, editing, deleting, and viewing blog posts and comments, with administrative controls for content management. Additionally, it describes the application database context and seeding data for initial setup, along with models for users, blog posts, comments, and error handling.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Blog controller

using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

namespace [Link]
{
public class BlogController : Controller
{
private readonly ApplicationDbContext _context;

public BlogController(ApplicationDbContext context)


{
_context = context;
}

// GET: /Blog - Read all blogs


public async Task<IActionResult> Index()
{
var blogs = await _context.BlogPosts
.Where(b => [Link])
.OrderByDescending(b => [Link])
.ToListAsync();
return View(blogs);
}

// GET: /Blog/Details/5 - Read single blog


public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}

var blog = await _context.BlogPosts


.FirstOrDefaultAsync(m => [Link] == id);

if (blog == null)
{
return NotFound();
}

// Get comments for this blog


var comments = await _context.Comments
.Where(c => [Link] == id)
.ToListAsync();
[Link] = comments;

return View(blog);
}

// GET: /Blog/Create - Create form


[Authorize(Roles = "Admin")]
public IActionResult Create()
{
// Add categories for dropdown
var categories = new List<string>
{
"General", "[Link]", "C#", "Database", "Web Development",
"Mobile Development", "JavaScript", "Python", "DevOps"
};
[Link] = new SelectList(categories);
return View();
}

// POST: /Blog/Create - Create action


[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admin")]
public async Task<IActionResult> Create(BlogPost blogPost)
{
if ([Link])
{
[Link] = [Link]([Link]);
[Link] = [Link];

_context.Add(blogPost);
await _context.SaveChangesAsync();

TempData["SuccessMessage"] = "Blog post created successfully!";


return RedirectToAction(nameof(Index));
}

// Repopulate categories if validation fails


var categories = new List<string>
{
"General", "[Link]", "C#", "Database", "Web Development",
"Mobile Development", "JavaScript", "Python", "DevOps"
};
[Link] = new SelectList(categories);
return View(blogPost);
}

// GET: /Blog/Edit/5 - Edit form


[Authorize(Roles = "Admin")]
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}

var blog = await _context.[Link](id);


if (blog == null)
{
return NotFound();
}

var categories = new List<string>


{
"General", "[Link]", "C#", "Database", "Web Development",
"Mobile Development", "JavaScript", "Python", "DevOps"
};
[Link] = new SelectList(categories, [Link]);
return View(blog);
}

// POST: /Blog/Edit/5 - Edit action


[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admin")]
public async Task<IActionResult> Edit(int id, BlogPost blogPost)
{
if (id != [Link])
{
return NotFound();
}

if ([Link])
{
try
{
_context.Update(blogPost);
await _context.SaveChangesAsync();
TempData["SuccessMessage"] = "Blog post updated successfully!";
}
catch (DbUpdateConcurrencyException)
{
if (!BlogPostExists([Link]))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}

var categories = new List<string>


{
"General", "[Link]", "C#", "Database", "Web Development",
"Mobile Development", "JavaScript", "Python", "DevOps"
};
[Link] = new SelectList(categories, [Link]);
return View(blogPost);
}

// GET: /Blog/Delete/5 - Delete confirmation


[Authorize(Roles = "Admin")]
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}

var blog = await _context.BlogPosts


.FirstOrDefaultAsync(m => [Link] == id);

if (blog == null)
{
return NotFound();
}

return View(blog);
}

// POST: /Blog/Delete/5 - Delete action


[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admin")]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var blog = await _context.[Link](id);
if (blog != null)
{
_context.[Link](blog);
await _context.SaveChangesAsync();
TempData["SuccessMessage"] = "Blog post deleted successfully!";
}
return RedirectToAction(nameof(Index));
}

private bool BlogPostExists(int id)


{
return _context.[Link](e => [Link] == id);
}
}
}

Comment controller:
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

namespace [Link]
{
public class CommentController : Controller
{
private readonly ApplicationDbContext _context;

public CommentController(ApplicationDbContext context)


{
_context = context;
}

// POST: /Comment/Create - Create comment


[HttpPost]
[ValidateAntiForgeryToken]
[Authorize]
public async Task<IActionResult> Create(int blogPostId, string content)
{
if ([Link](content))
{
TempData["ErrorMessage"] = "Comment cannot be empty!";
return RedirectToAction("Details", "Blog", new { id = blogPostId });
}

var comment = new Comment


{
Content = content,
CreatedDate = [Link],
UserId = [Link]([Link]),
BlogPostId = blogPostId
};

_context.[Link](comment);
await _context.SaveChangesAsync();

TempData["SuccessMessage"] = "Comment added successfully!";


return RedirectToAction("Details", "Blog", new { id = blogPostId });
}

// POST: /Comment/Delete/5 - Delete comment (Admin only)


[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Admin")]
public async Task<IActionResult> Delete(int id)
{
var comment = await _context.[Link](id);
if (comment != null)
{
var blogPostId = [Link];
_context.[Link](comment);
await _context.SaveChangesAsync();
TempData["SuccessMessage"] = "Comment deleted successfully!";
return RedirectToAction("Details", "Blog", new { id = blogPostId });
}
return NotFound();
}
}
}

Home controller
using [Link];
using [Link];
using [Link];
namespace [Link]
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger)


{
_logger = logger;
}

public IActionResult Index()


{
return View();
}

public IActionResult Privacy()


{
return View();
}

[ResponseCache(Duration = 0, Location = [Link], NoStore


= true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = [Link]?.Id ??
[Link] });
}
}
}

Application Db contest
using [Link];
using [Link];
using [Link];

namespace [Link]
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}

public DbSet<BlogPost> BlogPosts { get; set; }


public DbSet<Comment> Comments { get; set; }
}
}
SeedData:
using [Link];
using [Link];

namespace [Link]
{
public static class SeedData
{
public static async Task Initialize(IServiceProvider serviceProvider)
{
try
{
var userManager =
[Link]<UserManager<ApplicationUser>>();
var roleManager =
[Link]<RoleManager<IdentityRole>>();
var context =
[Link]<ApplicationDbContext>();

// 1. Create Roles
if (!await [Link]("Admin"))
{
await [Link](new IdentityRole("Admin"));
}

if (!await [Link]("User"))
{
await [Link](new IdentityRole("User"));
}

// 2. Create Admin User


var adminEmail = "admin@[Link]";
var adminPassword = "Admin@123";

if (await [Link](adminEmail) == null)


{
var admin = new ApplicationUser
{
UserName = adminEmail,
Email = adminEmail,
FullName = "Admin User"
};

var createResult = await [Link](admin,


adminPassword);

if ([Link])
{
await [Link](admin, "Admin");

// 3. Add Sample Blog Posts


await AddSampleBlogs(context, [Link]);
}
}

// 4. Create Regular User


var userEmail = "user@[Link]";
var userPassword = "User@123";

if (await [Link](userEmail) == null)


{
var user = new ApplicationUser
{
UserName = userEmail,
Email = userEmail,
FullName = "Regular User"
};

await [Link](user, userPassword);


await [Link](user, "User");
}
}
catch (Exception ex)
{
// Log error
var logger = [Link]<ILogger<Program>>();
[Link](ex, "An error occurred seeding the database.");
throw;
}
}

// Add this method to [Link]


private static async Task AddMoreSampleBlogs(ApplicationDbContext context,
string authorId)
{
if (![Link]())
{
var blogs = new[]
{
new BlogPost
{
Title = "Getting Started with .NET 9",
Content = "Learn about the new features in .NET 9 and how to upgrade
your projects.",
Category = ".NET",
CreatedDate = [Link](-2),
IsPublished = true,
AuthorId = authorId
},
new BlogPost
{
Title = "Entity Framework Core Best Practices",
Content = "Optimize your database operations with these EF Core tips
and tricks.",
Category = "Database",
CreatedDate = [Link](-1),
IsPublished = true,
AuthorId = authorId
},
new BlogPost
{
Title = "Building REST APIs with [Link] Core",
Content = "A comprehensive guide to building scalable REST APIs
using [Link] Core.",
Category = "API",
CreatedDate = [Link],
IsPublished = true,
AuthorId = authorId
}
};

await [Link](blogs);
await [Link]();
}
}
private static async Task AddSampleBlogs(ApplicationDbContext context,
string authorId)
{
// Check if blogs already exist
if (![Link]())
{
var blogs = new[]
{
new BlogPost
{
Title = "Welcome to Tech Blog",
Content = "This is our first blog post. Welcome to our tech
blog website!",
Category = "General",
CreatedDate = [Link](-5),
IsPublished = true,
AuthorId = authorId
},
new BlogPost
{
Title = "[Link] Core Tutorial",
Content = "Learn how to build web applications with [Link]
Core.",
Category = "[Link]",
CreatedDate = [Link](-3),
IsPublished = true,
AuthorId = authorId
},
new BlogPost
{
Title = "C# Programming Basics",
Content = "Introduction to C# programming language for
beginners.",
Category = "C#",
CreatedDate = [Link](-1),
IsPublished = true,
AuthorId = authorId
}
};

await [Link](blogs);
await [Link]();
}
}
}
}
Model aaplication user

using [Link];

namespace [Link]
{
public class ApplicationUser : IdentityUser
{
public string FullName { get; set; } = "";
}
}

Blogpost model
namespace [Link]
{
public class BlogPost
{
public int Id { get; set; }
public string Title { get; set; } = "";
public string Content { get; set; } = "";
public string Category { get; set; } = "General";
public DateTime CreatedDate { get; set; } = [Link];
public bool IsPublished { get; set; } = true;
public string AuthorId { get; set; } = "";
}
}

Comment model
namespace [Link]
{
public class Comment
{
public int Id { get; set; }
public string Content { get; set; } = "";
public DateTime CreatedDate { get; set; } = [Link];
public string UserId { get; set; } = "";
public int BlogPostId { get; set; }
}
}

Error view model


namespace [Link]
{
public class ErrorViewModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => ![Link](RequestId);


}
}

[Link]
using [Link];
using [Link];
using [Link];
using [Link];

var builder = [Link](args);

// Add services to the container.


var connectionString =
[Link]("DefaultConnection");
[Link]<ApplicationDbContext>(options =>
[Link](connectionString));

[Link]();

[Link]<ApplicationUser>(options =>
{
[Link] = false;
})
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();

[Link]();

var app = [Link]();

// Configure the HTTP request pipeline.


if ([Link]())
{
[Link]();
}
else
{
[Link]("/Home/Error");
[Link]();
}

[Link]();
[Link]();

[Link]();

[Link]();
[Link]();

[Link](
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
[Link]();

// Seed database with error handling


try
{
using (var scope = [Link]())
{
var services = [Link];
await [Link](services);
[Link]("Database seeded successfully!");
}
}
catch (Exception ex)
{
[Link]($"Error seeding database: {[Link]}");
}

[Link]();

Veiw Blog
(Create)
@model BlogPost
@{
ViewData["Title"] = "Create New Blog";
}

<div class="container mt-4">


<div class="row justify-content-center">
<div class="col-md-10">
<div class="card">
<div class="card-header bg-primary
text-white">
<h4 class="mb-0">
<i class="fas fa-plus-
circle"></i> @ViewData["Title"]
</h4>
</div>
<div class="card-body">
<form asp-action="Create">
<div asp-validation-
summary="ModelOnly" class="text-danger"></div>

<div class="mb-3">
<label asp-for="Title"
class="form-label">
<i class="fas fa-
heading"></i> Title
</label>
<input asp-for="Title"
class="form-control" placeholder="Enter blog title"
/>
<span asp-validation-
for="Title" class="text-danger"></span>
</div>

<div class="row mb-3">


<div class="col-md-6">
<label asp-
for="Category" class="form-label">
<i class="fas
fa-tag"></i> Category
</label>
<select asp-
for="Category" class="form-select" asp-
items="[Link]">
<option
value="">-- Select Category --</option>
</select>
<span asp-
validation-for="Category" class="text-
danger"></span>
</div>
<div class="col-md-6">
<div class="form-
check mt-4 pt-2">
<input asp-
for="IsPublished" class="form-check-input" />
<label asp-
for="IsPublished" class="form-check-label">
<i
class="fas fa-globe"></i> Publish immediately
</label>
</div>
</div>
</div>

<div class="mb-3">
<label asp-
for="Content" class="form-label">
<i class="fas fa-
edit"></i> Content
</label>
<textarea asp-
for="Content" class="form-control" rows="10"
placeholder="
Write your blog content here..."></textarea>
<span asp-validation-
for="Content" class="text-danger"></span>
</div>

<div class="d-flex justify-


content-between">
<a asp-action="Index"
class="btn btn-outline-secondary">
<i class="fas fa-
arrow-left"></i> Back to List
</a>
<button type="submit"
class="btn btn-primary">
<i class="fas fa-
save"></i> Create Blog
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>

@section Scripts {
@{
await
[Link]("_ValidationScriptsPartial"
);
}
}

Delete
@model BlogPost
@{
ViewData["Title"] = "Delete Blog";
}

<div class="container mt-4">


<div class="row justify-content-center">
<div class="col-md-8">
<div class="card border-danger">
<div class="card-header bg-danger
text-white">
<h4 class="mb-0">
<i class="fas fa-
exclamation-triangle"></i> @ViewData["Title"]
</h4>
</div>
<div class="card-body">
<div class="alert alert-
danger">
<h5><i class="fas fa-
exclamation-circle"></i> Warning!</h5>
<p class="mb-0">Are you
sure you want to delete this blog post? This action
cannot be undone.</p>
</div>

<div class="card mb-3">


<div class="card-body">
<h5 class="card-
title">@[Link]</h5>
<div class="row">
<div class="col-md-
6">
<p class="mb-
1"><strong>Category:</strong> @[Link]</p>
<p class="mb-
1"><strong>Created:</strong>
@[Link]("MMMM dd, yyyy")</p>
<p class="mb-
1">
<strong>Sta
tus:</strong>
@if
([Link])
{
<span
class="badge bg-success">Published</span>
}
else
{
<span
class="badge bg-warning">Draft</span>
}
</p>
</div>
<div class="col-md-
6">
<p class="mb-
1"><strong>Preview:</strong></p>
<p class="text-
muted">
@{
var
preview = [Link] > 100
?
[Link](0, 100) + "..."
:
[Link];
}
@preview
</p>
</div>
</div>
</div>
</div>

<form asp-action="Delete">
<input type="hidden" asp-
for="Id" />
<div class="d-flex justify-
content-between">
<a asp-action="Index"
class="btn btn-outline-secondary">
<i class="fas fa-
arrow-left"></i> Cancel
</a>
<button type="submit"
class="btn btn-danger">
<i class="fas fa-
trash"></i> Confirm Delete
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
Details
@model BlogPost
@{
ViewData["Title"] = [Link];
var comments = [Link] as
List<Comment> ?? new List<Comment>();
}

<div class="container mt-4">


<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a asp-
action="Index">Blogs</a></li>
<li class="breadcrumb-item
active">@[Link]</li>
</ol>
</nav>

<article class="card">
<div class="card-body">
<div class="d-flex justify-content-
between align-items-start mb-3">
<div>
<span class="badge bg-
primary">@[Link]</span>
@if (![Link])
{
<span class="badge bg-
warning">Draft</span>
}
</div>
<small class="text-muted">
<i class="far fa-calendar"></i>
@[Link]("MMMM dd, yyyy")
</small>
</div>

<h1 class="card-
title">@[Link]</h1>

<hr />

<div class="blog-content">
@[Link]([Link]("\n
", "<br>"))
</div>

<hr />

<div class="d-flex justify-content-


between align-items-center">
<a asp-action="Index" class="btn
btn-outline-secondary">
<i class="fas fa-arrow-
left"></i> Back to Blogs
</a>

@if ([Link]("Admin"))
{
<div>
<a asp-action="Edit" asp-
route-id="@[Link]" class="btn btn-warning">
<i class="fas fa-
edit"></i> Edit
</a>
<a asp-action="Delete" asp-
route-id="@[Link]" class="btn btn-danger">
<i class="fas fa-
trash"></i> Delete
</a>
</div>
}
</div>
</div>
</article>

<!-- Comments Section -->


<div class="card mt-4">
<div class="card-header bg-light">
<h5 class="mb-0">
<i class="fas fa-comments"></i>
Comments (@[Link])
</h5>
</div>

<div class="card-body">
<!-- Add Comment Form -->
@if ([Link])
{
<div class="mb-4">
<h6>Add a Comment</h6>
<form asp-controller="Comment"
asp-action="Create" method="post">
<input type="hidden"
name="blogPostId" value="@[Link]" />
<div class="mb-3">
<textarea
name="content" class="form-control" rows="3"
placeholder="Shar
e your thoughts..." required></textarea>
</div>
<button type="submit"
class="btn btn-primary">
<i class="fas fa-paper-
plane"></i> Post Comment
</button>
</form>
</div>
}
else
{
<div class="alert alert-info">
<i class="fas fa-info-
circle"></i> Please <a asp-area="Identity" asp-
page="/Account/Login">login</a> to post a comment.
</div>
}

<!-- Comments List -->


<div class="mt-4">
@if ([Link]())
{
<h6>All Comments</h6>
@foreach (var comment in
comments)
{
<div class="card comment-
card mb-3">
<div class="card-body">
<div class="d-flex
justify-content-between">
<div>
<strong>Use
r</strong>
<small
class="text-muted ms-2">
<i
class="far fa-clock"></i>
@[Link]("MMM dd, HH:mm")
</small>
</div>
@if
([Link]("Admin"))
{
<form asp-
controller="Comment" asp-action="Delete"
method="post">
<input
type="hidden" name="id" value="@[Link]" />
<button
type="submit" class="btn btn-sm btn-danger"

onclick="return confirm('Delete this comment?')">


<i
class="fas fa-trash"></i>
</butto
n>
</form>
}
</div>
<p class="card-text
mt-2">@[Link]</p>
</div>
</div>
}
}
else
{
<div class="text-center text-
muted py-3">
<i class="far fa-comment
fa-2x"></i>
<p class="mt-2">No comments
yet. Be the first to comment!</p>
</div>
}
</div>
</div>
</div>
</div>

Edit
@model BlogPost
@{
ViewData["Title"] = "Edit Blog";
}

<div class="container mt-4">


<div class="row justify-content-center">
<div class="col-md-10">
<div class="card">
<div class="card-header bg-warning
text-white">
<h4 class="mb-0">
<i class="fas fa-edit"></i>
@ViewData["Title"]
</h4>
</div>
<div class="card-body">
<form asp-action="Edit">
<input type="hidden" asp-
for="Id" />

<div class="mb-3">
<label asp-for="Title"
class="form-label">
<i class="fas fa-
heading"></i> Title
</label>
<input asp-for="Title"
class="form-control" />
<span asp-validation-
for="Title" class="text-danger"></span>
</div>

<div class="row mb-3">


<div class="col-md-6">
<label asp-
for="Category" class="form-label">
<i class="fas
fa-tag"></i> Category
</label>
<select asp-
for="Category" class="form-select" asp-
items="[Link]">
<option
value="">-- Select Category --</option>
</select>
<span asp-
validation-for="Category" class="text-
danger"></span>
</div>
<div class="col-md-6">
<div class="form-
check mt-4 pt-2">
<input asp-
for="IsPublished" class="form-check-input" />
<label asp-
for="IsPublished" class="form-check-label">
<i
class="fas fa-globe"></i> Published
</label>
</div>
</div>
</div>

<div class="mb-3">
<label asp-
for="Content" class="form-label">
<i class="fas fa-
edit"></i> Content
</label>
<textarea asp-
for="Content" class="form-control"
rows="10"></textarea>
<span asp-validation-
for="Content" class="text-danger"></span>
</div>

<div class="d-flex justify-


content-between">
<a asp-action="Index"
class="btn btn-outline-secondary">
<i class="fas fa-
arrow-left"></i> Cancel
</a>
<button type="submit"
class="btn btn-warning">
<i class="fas fa-
save"></i> Save Changes
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>

@section Scripts {
@{
await
[Link]("_ValidationScriptsPartial"
);
}
}

Index
@model IEnumerable<BlogPost>

@{
ViewData["Title"] = "Tech Blogs";
}

<div class="container mt-4">


<div class="row">
<div class="col-md-8">
<h1 class="mb-4">
<i class="fas fa-newspaper text-
primary"></i> Tech Blogs
<small class="text-muted">Latest
technology articles</small>
</h1>
</div>
<div class="col-md-4 text-end">
@if ([Link]("Admin"))
{
<a asp-action="Create" class="btn
btn-primary btn-lg">
<i class="fas fa-plus"></i>
Create New Blog
</a>
}
</div>
</div>

<div class="row">
@foreach (var blog in Model)
{
<div class="col-md-6">
<div class="card">
<div class="card-body">
<div class="d-flex justify-
content-between align-items-start">
<div>
<span class="badge
bg-info category-badge">@[Link]</span>
@if
(![Link])
{
<span
class="badge bg-warning category-
badge">Draft</span>
}
</div>
<small class="text-
muted">
<i class="far fa-
calendar"></i> @[Link]("MMM dd,
yyyy")
</small>
</div>

<h5 class="card-title mt-


2">
<a asp-action="Details"
asp-route-id="@[Link]" class="text-decoration-none
text-dark">
@[Link]
</a>
</h5>

<p class="card-text text-


muted">
@{
var summary =
[Link] > 150
?
[Link](0, 150) + "..."
: [Link];
}
@summary
</p>

<div class="d-flex justify-


content-between align-items-center">
<a asp-action="Details"
asp-route-id="@[Link]" class="btn btn-outline-
primary btn-sm">
<i class="fas fa-
readme"></i> Read More
</a>

<div>
@if
([Link]("Admin"))
{
<a asp-
action="Edit" asp-route-id="@[Link]" class="btn
btn-warning btn-sm btn-action">
<i
class="fas fa-edit"></i> Edit
</a>
<a asp-
action="Delete" asp-route-id="@[Link]" class="btn
btn-danger btn-sm btn-action">
<i
class="fas fa-trash"></i> Delete
</a>
}
</div>
</div>
</div>
</div>
</div>
}
</div>

@if (![Link]())
{
<div class="text-center py-5">
<i class="fas fa-newspaper fa-4x text-
muted mb-3"></i>
<h3 class="text-muted">No blog posts
yet</h3>
@if ([Link]("Admin"))
{
<p class="lead">Be the first to
create a blog post!</p>
<a asp-action="Create" class="btn
btn-primary btn-lg">
<i class="fas fa-plus"></i>
Create Your First Blog
</a>
}
else
{
<p class="lead">Check back soon for
new posts!</p>
}
</div>
}
</div>

Home
Index
@{
ViewData["Title"] = "Home - Tech Blog";
}

<div class="hero-section text-center py-5">


<div class="container">
<h1 class="display-4 fw-bold mb-4 text-
gradient">
<i class="fas fa-code me-3"></i>Welcome
to Tech Blog
</h1>
<p class="lead mb-4">
Your ultimate destination for
technology insights, tutorials, and industry
trends.
Stay updated with the latest in
software development, programming, and tech
innovations.
</p>

<div class="cta-buttons mt-5">


<a asp-controller="Blog" asp-
action="Index" class="btn btn-primary btn-lg me-3
px-4 py-3">
<i class="fas fa-newspaper me-
2"></i>Explore Blogs
</a>
@if (![Link])
{
<a asp-area="Identity" asp-
page="/Account/Register" class="btn btn-outline-
primary btn-lg px-4 py-3">
<i class="fas fa-user-plus me-
2"></i>Join Our Community
</a>
}
</div>
</div>
</div>
<!-- Features Section -->
<div class="container py-5">
<div class="row text-center mb-5">
<div class="col">
<h2 class="fw-bold">
<i class="fas fa-star me-2 text-
warning"></i>Why Choose Tech Blog?
</h2>
<p class="text-muted">Discover the
features that make us unique</p>
</div>
</div>

<div class="row g-4">


<div class="col-md-4">
<div class="feature-card p-4 text-
center h-100">
<div class="feature-icon mb-4">
<i class="fas fa-laptop-code
fa-3x text-primary"></i>
</div>
<h4 class="fw-bold mb-3">Latest
Tech Content</h4>
<p class="text-muted">
Stay updated with cutting-edge
technology trends, tutorials, and industry insights
from experienced developers and
tech enthusiasts.
</p>
</div>
</div>

<div class="col-md-4">
<div class="feature-card p-4 text-
center h-100">
<div class="feature-icon mb-4">
<i class="fas fa-comments fa-3x
text-success"></i>
</div>
<h4 class="fw-bold mb-
3">Interactive Community</h4>
<p class="text-muted">
Engage with fellow tech
enthusiasts through comments, discussions,
and knowledge sharing in our
vibrant community.
</p>
</div>
</div>

<div class="col-md-4">
<div class="feature-card p-4 text-
center h-100">
<div class="feature-icon mb-4">
<i class="fas fa-shield-alt fa-
3x text-info"></i>
</div>
<h4 class="fw-bold mb-3">Secure
Platform</h4>
<p class="text-muted">
Your data and privacy are our
top priority. We implement industry-standard
security measures to protect
your information.
</p>
</div>
</div>
</div>
</div>

<!-- Recent Blogs Section -->


<div class="bg-light py-5">
<div class="container">
<div class="row mb-4">
<div class="col">
<h2 class="fw-bold">
<i class="fas fa-fire me-2
text-danger"></i>Recent Blog Posts
</h2>
<p class="text-muted">Check out our
latest technology articles</p>
</div>
<div class="col text-end">
<a asp-controller="Blog" asp-
action="Index" class="btn btn-outline-primary">
View All <i class="fas fa-
arrow-right ms-2"></i>
</a>
</div>
</div>

<div class="row">
<!-- Blog cards will be dynamically
loaded from database -->
<div class="col-md-6">
<div class="card blog-preview-card
mb-4">
<div class="card-body">
<span class="badge bg-
primary mb-3">[Link]</span>
<h5 class="card-title fw-
bold">Getting Started with [Link] Core</h5>
<p class="card-text text-
muted">
Learn the fundamentals
of building web applications with [Link] Core
and explore its
powerful features for modern web development.
</p>
<div class="d-flex justify-
content-between align-items-center">
<small class="text-
muted">
<i class="far fa-
clock me-1"></i> 2 days ago
</small>
<a href="#" class="btn
btn-sm btn-outline-primary">Read More</a>
</div>
</div>
</div>
</div>

<div class="col-md-6">
<div class="card blog-preview-card
mb-4">
<div class="card-body">
<span class="badge bg-
success mb-3">C#</span>
<h5 class="card-title fw-
bold">C# 12 New Features</h5>
<p class="card-text text-
muted">
Explore the latest
features introduced in C# 12 and learn how to
leverage them to write
cleaner, more efficient code.
</p>
<div class="d-flex justify-
content-between align-items-center">
<small class="text-
muted">
<i class="far fa-
clock me-1"></i> 1 week ago
</small>
<a href="#" class="btn
btn-sm btn-outline-primary">Read More</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<!-- Stats Section -->


<div class="container py-5">
<div class="row text-center">
<div class="col-md-3 col-6 mb-4">
<div class="stat-card">
<i class="fas fa-newspaper fa-2x
text-primary mb-3"></i>
<h3 class="fw-bold counter" data-
target="50">0</h3>
<p class="text-muted">Blog
Posts</p>
</div>
</div>
<div class="col-md-3 col-6 mb-4">
<div class="stat-card">
<i class="fas fa-users fa-2x text-
success mb-3"></i>
<h3 class="fw-bold counter" data-
target="1000">0</h3>
<p class="text-muted">Community
Members</p>
</div>
</div>
<div class="col-md-3 col-6 mb-4">
<div class="stat-card">
<i class="fas fa-comment fa-2x
text-info mb-3"></i>
<h3 class="fw-bold counter" data-
target="500">0</h3>
<p class="text-muted">Comments</p>
</div>
</div>
<div class="col-md-3 col-6 mb-4">
<div class="stat-card">
<i class="fas fa-eye fa-2x text-
warning mb-3"></i>
<h3 class="fw-bold counter" data-
target="10000">0</h3>
<p class="text-muted">Monthly
Views</p>
</div>
</div>
</div>
</div>

<!-- Call to Action -->


<div class="bg-primary text-white py-5">
<div class="container text-center">
<h2 class="fw-bold mb-4">Ready to Join Our
Tech Community?</h2>
<p class="mb-4 lead">
Share your knowledge, learn from
others, and stay ahead in the tech world.
</p>
@if (![Link])
{
<a asp-area="Identity" asp-
page="/Account/Register" class="btn btn-light btn-
lg px-5 py-3">
<i class="fas fa-rocket me-
2"></i>Get Started Now
</a>
}
else
{
<a asp-controller="Blog" asp-
action="Create" class="btn btn-light btn-lg px-5
py-3">
<i class="fas fa-pen me-
2"></i>Write Your First Blog
</a>
}
</div>
</div>

<style>
.hero-section {
background: linear-gradient(135deg, #667eea
0%, #764ba2 100%);
color: white;
border-radius: 20px;
margin: 20px auto;
max-width: 95%;
box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.text-gradient {
background: linear-gradient(90deg, #ff7e5f,
#feb47b);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.feature-card {
background: white;
border-radius: 15px;
box-shadow: 0 5px 20px rgba(0,0,0,0.08);
transition: transform 0.3s ease;
border: 1px solid #eef2f7;
}

.feature-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

.feature-icon {
width: 80px;
height: 80px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
background: rgba(102, 126, 234, 0.1);
border-radius: 50%;
}

.blog-preview-card {
border: none;
border-radius: 15px;
box-shadow: 0 5px 15px rgba(0,0,0,0.08);
transition: all 0.3s ease;
height: 100%;
}

.blog-preview-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.stat-card {
padding: 30px 20px;
background: white;
border-radius: 15px;
box-shadow: 0 5px 15px rgba(0,0,0,0.08);
transition: all 0.3s ease;
}

.stat-card:hover {
transform: scale(1.05);
box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.counter {
font-size: 2.5rem;
color: #333;
}
.btn-primary, .btn-outline-primary:hover {
background: linear-gradient(135deg, #667eea
0%, #764ba2 100%);
border: none;
}

.btn-outline-primary {
border: 2px solid #667eea;
color: #667eea;
}

.btn-lg {
font-weight: 600;
border-radius: 12px;
}
</style>

<script>
// Counter animation
[Link]('DOMContentLoaded',
function() {
const counters =
[Link]('.counter');
const speed = 200;

[Link](counter => {
const animate = () => {
const value =
+[Link]('data-target');
const data = +[Link];

const time = value / speed;


if (data < value) {
[Link] =
[Link](data + time);
setTimeout(animate, 1);
} else {
[Link] = value;
}
}
animate();
});
});
</script>

Privacy
@{
ViewData["Title"] = "Privacy Policy";
}

<div class="container py-5">


<div class="row justify-content-center">
<div class="col-lg-10">
<!-- Header -->
<div class="text-center mb-5">
<h1 class="display-4 fw-bold mb-3
text-gradient">
<i class="fas fa-shield-alt me-
2"></i>Privacy Policy
</h1>
<p class="lead text-muted">
Your privacy is important to
us. This policy explains how we collect, use, and
protect your information.
</p>
<div class="badge bg-primary p-2
px-4 mb-3">
Last Updated:
@[Link]("MMMM dd, yyyy")
</div>
</div>

<!-- Table of Contents -->


<div class="card shadow-sm mb-5">
<div class="card-header bg-light">
<h5 class="mb-0">
<i class="fas fa-list me-
2"></i>Table of Contents
</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<ul class="list-
unstyled">
<li class="mb-2">
<a
href="#information-collected" class="text-
decoration-none">
<i
class="fas fa-chevron-right text-primary me-
2"></i>Information We Collect
</a>
</li>
<li class="mb-2">
<a href="#data-
usage" class="text-decoration-none">
<i
class="fas fa-chevron-right text-primary me-
2"></i>How We Use Your Data
</a>
</li>
<li class="mb-2">
<a href="#data-
protection" class="text-decoration-none">
<i
class="fas fa-chevron-right text-primary me-
2"></i>Data Protection
</a>
</li>
</ul>
</div>
<div class="col-md-6">
<ul class="list-
unstyled">
<li class="mb-2">
<a
href="#cookies" class="text-decoration-none">
<i
class="fas fa-chevron-right text-primary me-
2"></i>Cookies Policy
</a>
</li>
<li class="mb-2">
<a href="#user-
rights" class="text-decoration-none">
<i
class="fas fa-chevron-right text-primary me-
2"></i>Your Rights
</a>
</li>
<li class="mb-2">
<a
href="#contact" class="text-decoration-none">
<i
class="fas fa-chevron-right text-primary me-
2"></i>Contact Us
</a>
</li>
</ul>
</div>
</div>
</div>
</div>

<!-- Privacy Content -->


<div class="privacy-content">

<!-- Section 1 -->


<div id="information-collected"
class="privacy-section card shadow-sm mb-4">
<div class="card-header bg-
primary text-white">
<h4 class="mb-0">
<i class="fas fa-
database me-2"></i>Information We Collect
</h4>
</div>
<div class="card-body">
<div class="row mb-4">
<div class="col-md-6">
<div class="info-
card p-3 mb-3">
<div class="d-
flex align-items-center mb-2">
<div
class="icon-box bg-primary me-3">
<i
class="fas fa-user text-white"></i>
</div>
<h5
class="mb-0">Personal Information</h5>
</div>
<p class="mb-0
text-muted">
When you
register, we collect your name, email address, and
other information you provide.
</p>
</div>
</div>
<div class="col-md-6">
<div class="info-
card p-3 mb-3">
<div class="d-
flex align-items-center mb-2">
<div
class="icon-box bg-success me-3">
<i
class="fas fa-blog text-white"></i>
</div>
<h5
class="mb-0">Content Information</h5>
</div>
<p class="mb-0
text-muted">
Blog posts,
comments, and any other content you create on our
platform.
</p>
</div>
</div>
</div>

<div class="alert alert-


info">
<i class="fas fa-info-
circle me-2"></i>
<strong>Note:</strong>
We never sell your personal information to third
parties.
</div>
</div>
</div>

<!-- Section 2 -->


<div id="data-usage"
class="privacy-section card shadow-sm mb-4">
<div class="card-header bg-
success text-white">
<h4 class="mb-0">
<i class="fas fa-chart-
line me-2"></i>How We Use Your Data
</h4>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-4
text-center mb-4">
<div class="usage-
icon mb-3">
<i class="fas
fa-user-check fa-2x text-primary"></i>
</div>
<h5>Account
Management</h5>
<p class="text-
muted small">To create and manage your account</p>
</div>
<div class="col-md-4
text-center mb-4">
<div class="usage-
icon mb-3">
<i class="fas
fa-comments fa-2x text-success"></i>
</div>
<h5>Community
Features</h5>
<p class="text-
muted small">To enable comments and
interactions</p>
</div>
<div class="col-md-4
text-center mb-4">
<div class="usage-
icon mb-3">
<i class="fas
fa-envelope fa-2x text-warning"></i>
</div>
<h5>Communication</
h5>
<p class="text-
muted small">To send important updates and
notifications</p>
</div>
</div>
</div>
</div>

<!-- Section 3 -->


<div id="data-protection"
class="privacy-section card shadow-sm mb-4">
<div class="card-header bg-info
text-white">
<h4 class="mb-0">
<i class="fas fa-lock
me-2"></i>Data Protection
</h4>
</div>
<div class="card-body">
<div class="security-
features">
<div class="row align-
items-center mb-4">
<div class="col-md-
2 text-center">
<i class="fas
fa-shield-alt fa-3x text-success"></i>
</div>
<div class="col-md-
10">
<h5>Encryption<
/h5>
<p class="text-
muted mb-0">
All data
transmitted between your browser and our servers is
encrypted using SSL/TLS technology.
</p>
</div>
</div>
<div class="row align-
items-center mb-4">
<div class="col-md-
2 text-center">
<i class="fas
fa-server fa-3x text-primary"></i>
</div>
<div class="col-md-
10">
<h5>Secure
Servers</h5>
<p class="text-
muted mb-0">
Your data
is stored on secure servers with regular security
updates and monitoring.
</p>
</div>
</div>

<div class="row align-


items-center">
<div class="col-md-
2 text-center">
<i class="fas
fa-user-shield fa-3x text-warning"></i>
</div>
<div class="col-md-
10">
<h5>Access
Control</h5>
<p class="text-
muted mb-0">
Strict
access controls ensure only authorized personnel
can access user data.
</p>
</div>
</div>
</div>
</div>
</div>

<!-- Section 4 -->


<div id="cookies" class="privacy-
section card shadow-sm mb-4">
<div class="card-header bg-
warning text-dark">
<h4 class="mb-0">
<i class="fas fa-
cookie-bite me-2"></i>Cookies Policy
</h4>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<div class="cookie-
type p-3 mb-3">
<h6 class="fw-
bold">
<span
class="badge bg-primary me-2">Essential</span>
Necessary Cookies
</h6>
<p class="small
text-muted mb-0">
Required
for basic site functionality. Cannot be disabled.
</p>
</div>
</div>
<div class="col-md-6">
<div class="cookie-
type p-3 mb-3">
<h6 class="fw-
bold">
<span
class="badge bg-success me-2">Analytics</span>
Performance Cookies
</h6>
<p class="small
text-muted mb-0">
Help us
understand how visitors interact with our website.
</p>
</div>
</div>
</div>

<div class="alert alert-


warning">
<i class="fas fa-
exclamation-triangle me-2"></i>
You can manage your
cookie preferences through your browser settings.
</div>
</div>
</div>

<!-- Section 5 -->


<div id="user-rights"
class="privacy-section card shadow-sm mb-4">
<div class="card-header bg-dark
text-white">
<h4 class="mb-0">
<i class="fas fa-user-
check me-2"></i>Your Rights
</h4>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<ul class="list-
unstyled">
<li class="mb-
3">
<i
class="fas fa-check-circle text-success me-2"></i>
<strong>Rig
ht to Access</strong> - View your personal data
</li>
<li class="mb-
3">
<i
class="fas fa-edit text-primary me-2"></i>
<strong>Rig
ht to Rectify</strong> - Correct inaccurate data
</li>
<li class="mb-
3">
<i
class="fas fa-trash-alt text-danger me-2"></i>
<strong>Rig
ht to Delete</strong> - Request data deletion
</li>
</ul>
</div>
<div class="col-md-6">
<ul class="list-
unstyled">
<li class="mb-
3">
<i
class="fas fa-download text-info me-2"></i>
<strong>Dat
a Portability</strong> - Receive your data in
machine-readable format
</li>
<li class="mb-
3">
<i
class="fas fa-ban text-warning me-2"></i>
<strong>Rig
ht to Object</strong> - Object to certain data
processing
</li>
<li class="mb-
3">
<i
class="fas fa-cog text-secondary me-2"></i>
<strong>Con
sent Withdrawal</strong> - Withdraw consent at any
time
</li>
</ul>
</div>
</div>
</div>
</div>

<!-- Section 6 -->


<div id="contact" class="privacy-
section card shadow-sm">
<div class="card-header bg-
gradient text-white">
<h4 class="mb-0">
<i class="fas fa-
envelope me-2"></i>Contact Us
</h4>
</div>
<div class="card-body">
<div class="row align-
items-center">
<div class="col-md-8">
<h5 class="mb-
3">Have Questions About Our Privacy Policy?</h5>
<p class="text-
muted">
If you have any
questions, concerns, or requests regarding our
privacy practices,
please don't
hesitate to contact our privacy team.
</p>
<div
class="contact-info mt-4">
<div class="d-
flex align-items-center mb-3">
<div
class="contact-icon me-3">
<i
class="fas fa-envelope fa-lg text-primary"></i>
</div>
<div>
<h6
class="mb-0">Email</h6>
<p
class="text-muted mb-0">Imtiaz@[Link]</p>
</div>
</div>

<div class="d-
flex align-items-center mb-3">
<div
class="contact-icon me-3">
<i
class="fas fa-phone fa-lg text-success"></i>
</div>
<div>
<h6
class="mb-0">Phone</h6>
<p
class="text-muted mb-0">+8801568016429</p>
</div>
</div>

<div class="d-
flex align-items-center">
<div
class="contact-icon me-3">
<i
class="fas fa-clock fa-lg text-warning"></i>
</div>
<div>
<h6
class="mb-0">Response Time</h6>
<p
class="text-muted mb-0">Within 48 hours during
business days</p>
</div>
</div>
</div>
</div>

<div class="col-md-4
text-center">
<div
class="contact-illustration">
<i class="fas
fa-headset fa-6x text-primary opacity-75"></i>
</div>
</div>
</div>
</div>
</div>
</div>

<!-- Back to Top Button -->


<div class="text-center mt-5">
<a href="#" class="btn btn-primary"
id="backToTop">
<i class="fas fa-arrow-up me-
2"></i>Back to Top
</a>
</div>
</div>
</div>
</div>

<style>
.hero-section {
background: linear-gradient(135deg, #667eea
0%, #764ba2 100%);
color: white;
border-radius: 20px;
margin: 20px auto;
max-width: 95%;
box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.text-gradient {
color: #667eea;
background: linear-gradient(90deg, #ff7e5f,
#feb47b);
background-clip: border-box;
-webkit-background-clip: border-box;
}

.feature-card {
background: white;
border-radius: 15px;
box-shadow: 0 5px 20px rgba(0,0,0,0.08);
transition: transform 0.3s ease;
border: 1px solid #eef2f7;
}

.feature-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px
rgba(0,0,0,0.15);
}

.feature-icon {
width: 80px;
height: 80px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
background: rgba(102, 126, 234, 0.1);
border-radius: 50%;
}

.blog-preview-card {
border: none;
border-radius: 15px;
box-shadow: 0 5px 15px rgba(0,0,0,0.08);
transition: all 0.3s ease;
height: 100%;
}

.blog-preview-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px
rgba(0,0,0,0.15);
}

.stat-card {
padding: 30px 20px;
background: white;
border-radius: 15px;
box-shadow: 0 5px 15px rgba(0,0,0,0.08);
transition: all 0.3s ease;
}

.stat-card:hover {
transform: scale(1.05);
box-shadow: 0 10px 25px
rgba(0,0,0,0.15);
}

.counter {
font-size: 2.5rem;
color: #333;
}

.btn-primary, .btn-outline-primary:hover {
background: linear-gradient(135deg, #667eea
0%, #764ba2 100%);
border: none;
}

.btn-outline-primary {
border: 2px solid #667eea;
color: #667eea;
}

.btn-lg {
font-weight: 600;
border-radius: 12px;
}
</style>

<script>
[Link]('DOMContentLoaded',
function() {
// Smooth scrolling for table of contents
links
[Link]('a[href^="#"]').f
orEach(anchor => {
[Link]('click',
function(e) {
[Link]();
const targetId =
[Link]('href');
if (targetId === '#') return;

const targetElement =
[Link](targetId);
if (targetElement) {
[Link]({
top:
[Link] - 100,
behavior: 'smooth'
});
}
});
});
// Back to top button
const backToTopButton =
[Link]('backToTop');
[Link]('scroll',
function() {
if ([Link] > 300) {
[Link] =
'block';
} else {
[Link] =
'none';
}
});

[Link]('click',
function(e) {
[Link]();
[Link]({
top: 0,
behavior: 'smooth'
});
});

// Add active class to current section


const sections =
[Link]('.privacy-section');
const navLinks =
[Link]('a[href^="#"]');

[Link]('scroll',
function() {
let current = '';
[Link](section => {
const sectionTop =
[Link];
const sectionHeight =
[Link];
if (pageYOffset >= sectionTop -
150) {
current =
[Link]('id');
}
});

[Link](link => {
[Link]('active');
if ([Link]('href') ===
`#${current}`) {
[Link]('active');
}
});
});
});
</script>
Layout
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-
width, initial-scale=1.0" />
<title>@ViewData["Title"] - Tech Blog</title>
<link rel="stylesheet"
href="~/lib/bootstrap/dist/css/[Link]"
/>
<link rel="stylesheet"
href="[Link]
awesome/6.0.0/css/[Link]" />
<link rel="stylesheet" href="~/css/[Link]"
asp-append-version="true" />
<style>
body {
background-color: #f8f9fa;
}

.navbar {
box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.card {
transition: transform 0.3s;
margin-bottom: 20px;
border: none;
box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 8px
rgba(0,0,0,.15);
}

.btn-action {
margin-right: 5px;
}

.blog-content {
line-height: 1.8;
font-size: 1.1rem;
}

.category-badge {
font-size: 0.8rem;
margin-right: 5px;
}

.comment-card {
border-left: 3px solid #007bff;
margin-bottom: 10px;
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-
toggleable-sm navbar-dark bg-primary border-bottom
box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area=""
asp-controller="Home" asp-action="Index">
<i class="fas fa-blog"></i>
Tech Blog
</a>
<button class="navbar-toggler"
type="button" data-bs-toggle="collapse" data-bs-
target=".navbar-collapse">
<span class="navbar-toggler-
icon"></span>
</button>
<div class="navbar-collapse
collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-
grow-1">
<li class="nav-item">
<a class="nav-link"
asp-controller="Home" asp-action="Index">
<i class="fas fa-
home"></i> Home
</a>
</li>
<li class="nav-item">
<a class="nav-link"
asp-controller="Blog" asp-action="Index">
<i class="fas fa-
newspaper"></i> Blogs
</a>
</li>
@if
([Link]("Admin"))
{
<li class="nav-item">
<a class="nav-link"
asp-controller="Blog" asp-action="Create">
<i class="fas
fa-plus-circle"></i> New Post
</a>
</li>
}
<li class="nav-item">
<a class="nav-link"
asp-controller="Home" asp-action="Privacy">
<i class="fas fa-
shield-alt"></i> Privacy
</a>
</li>
</ul>
<partial name="_LoginPartial"
/>
</div>
</div>
</nav>
</header>

<div class="container">
<main role="main" class="pb-3">
<!-- Success/Error Messages -->
@if (TempData["SuccessMessage"] !=
null)
{
<div class="alert alert-success
alert-dismissible fade show" role="alert">
@TempData["SuccessMessage"]
<button type="button"
class="btn-close" data-bs-dismiss="alert"></button>
</div>
}
@if (TempData["ErrorMessage"] != null)
{
<div class="alert alert-danger
alert-dismissible fade show" role="alert">
@TempData["ErrorMessage"]
<button type="button"
class="btn-close" data-bs-dismiss="alert"></button>
</div>
}

@RenderBody()
</main>
</div>

<footer class="border-top footer text-muted bg-


light">
<div class="container">
<div class="row">
<div class="col-md-6">
&copy; 2024 - Tech Blog - <a
asp-area="" asp-controller="Home" asp-
action="Privacy">Privacy</a>
</div>
<div class="col-md-6 text-end">
<span class="text-muted">CSC
440 Project - Visual Programming Lab</span>
</div>
</div>
</div>
</footer>

<script
src="~/lib/jquery/dist/[Link]"></script>
<script
src="~/lib/bootstrap/dist/js/[Link].j
s"></script>
<script src="~/js/[Link]" asp-append-
version="true"></script>
@await RenderSectionAsync("Scripts", required:
false)
</body>
</html>

Layout partial
@using [Link]
@using [Link]
@inject SignInManager<ApplicationUser>
SignInManager
@inject UserManager<ApplicationUser> UserManager

<ul class="navbar-nav">
@if ([Link](User))
{
<li class="nav-item">
<a id="manage" class="nav-link text-
light" asp-area="Identity" asp-
page="/Account/Manage/Index" title="Manage">
<i class="fas fa-user"></i> Hello
@[Link](User)!
</a>
</li>
<li class="nav-item">
<form id="logoutForm" class="form-
inline" asp-area="Identity" asp-
page="/Account/Logout" asp-route-
returnUrl="@[Link]("Index", "Home", new { area
= "" })">
<button id="logout" type="submit"
class="nav-link btn btn-link text-light border-0">
<i class="fas fa-sign-out-
alt"></i> Logout
</button>
</form>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-light"
id="register" asp-area="Identity" asp-
page="/Account/Register">
<i class="fas fa-user-plus"></i>
Register
</a>
</li>
<li class="nav-item">
<a class="nav-link text-light"
id="login" asp-area="Identity" asp-
page="/Account/Login">
<i class="fas fa-sign-in-alt"></i>
Login
</a>
</li>
}
</ul>

You might also like