
Explore building a complete commerce app with ASP.NET Core Razor Pages and SQL Server, featuring a shopping cart, search, category filters, checkout, and admin CRUD for books, users, and orders.
Build a traditional contact form in an ASP.NET Core web app using a SQL client, with field validation, data annotations, and admin features for paging, details, deletion, and email confirmations.
Connect to sql server via server explorer, create a database named best chop, and create The Messages table with id, first name, last name, email, phone, subject, message, created at.
Create a contact form as a Razor Page in pages folder with first name, last name, email, phone, subject, and message. Submit via post and add to layout menu.
Demonstrate traditional form validation by defining public properties for form fields, validating required fields, saving data to the database, and sending a confirmation email with success or error alerts.
Build a robust contact form in ASP.NET Core Razor Pages by binding fields with data annotations, applying required and email validations, and using tag helpers for validation.
Insert messages into the messages table with first name, last name, email, phone, subject, and message, using the connection string and server explorer, then test.
Create a Razor Pages details page that reads a message ID from the query, fetches data from the messages table, and displays all fields.
Implement a delete message page in an ASP.NET Core Razor Pages app by reading the id from the query string and performing an SQL delete on the messages table.
Learn traditional CRUD operations on books using SQL Server and the SQL client, including create, read, update, delete, search, sort, pagination, image upload, and form validation.
Connects to an SQL Server database, creates a books table with ID, ISBN, title, author, pages, price, category, description, image filename, seeds data, and adds images to public/images/books.
Learn to implement sort functionality in a Razor Pages books table by ID, title, authors, pages, price, category, or created at, using clickable headers and a sortTable function.
Inject a web host environment to obtain the public folder path, then save uploaded images to the server with a timestamp-based unique name and proper extension in the books/images folder.
Update the book image by uploading a new file, generating a timestamped file name, and saving it to the public images/books folder while removing the old image.
Delete a book in an ASP.NET Core Razor Pages app by reading id from the URL, removing the book via SQL, deleting its image file, and redirecting to books list.
Learn to fix empty images by replacing an asynchronous image-saving function with a synchronous one in the create and edit models of an ASP.NET Core Razor Pages app.
Explore traditional authentication without entity framework or identity, using session data and the SQL client namespace to register clients, manage profiles, change user roles, and reset passwords via email confirmations.
Add two tables: a users table with id, email (unique), and role, plus a password reset table with email and token, created at.
Add register and login buttons to the navbar via the shared layout, and show administrator or client dropdowns based on authentication and role.
Create a register page in Razor Pages with bound properties and data annotations for validation, handle post requests to validate input, and show error or success messages.
Connect to the database, read the user by email, and verify the password against the encrypted password using a hash; on success, create the session and redirect to home page.
Create a simple Razor Pages logout view in the earth folder, clear the session, and redirect to home, then update the layout menu with logout links for admin and client.
Implement two custom attributes to protect pages and check user roles in Razor Pages, decorating the model and redirecting unauthorized users via session data.
Implement forgot password token handling by updating the database: delete old tokens for the email and insert a new token, then test by receiving the reset link.
Create a reset password form for unauthenticated users, read the token from the URL, bind new and confirm password, validate inputs, and show bootstrap-styled success or error messages.
Connect to the database, validate the token, read the email from the password reset table, encrypt and update the password in the users table, then delete the token.
Create a profile page that reads user details from session data and displays them in read only fields, with require auth access, and add the profile to the menu.
Update the profile page with a single bound form that updates user details or password via two submit buttons, using model validation and session-based prefill in a bootstrap modal.
Implement pagination for the users table by reading the page from the query string, calculating pages with a page size, and fetching only the current page using skip and take.
Update the home page by adding a hero section, a newest books section, and a top sales books section, with a responsive two-column layout, a search field, and bootstrap styling.
Read the shopping cart cookie on the server in a Razor Pages layout, using null-coalescing to an empty string, then count items by splitting on hyphens and show cart size.
Display book's details on a razor page using a two-column layout with a sticky image, add-to-cart button, and fields for title, ISBN, pages, price, category, and description, styled with bootstrap.
Display a book list in a bootstrap-styled table, showing each book’s image and description with title, authors, category, pages, and price, plus details and add-to-cart buttons.
Implement pagination for books model by defining page, totalPages, and pageSize, defaulting to page one. Read the page from the query string and display five books per page using Bootstrap.
Create and initialize an order item class to store book details, copies, and total price, then build a public list of order items in the ASP.NET Core Razor Pages model.
Convert the shopping cart cookie into a dictionary of book IDs (string) and copies (int) by reading, splitting on hyphens, and updating counts for request handling.
Implement cart item controls in razor pages to add, subtract, or delete books, update a cookie-based shopping cart, and redirect to refresh the page after each action.
Demonstrates a Razor Pages checkout flow that posts the form to create an order and its items in the database, using session for client id and validating input.
Create an admin orders page to view orders, define order item and order models with key fields, and implement a static get order items method to populate from the database.
Display an admin list of orders with Razor Pages and Bootstrap, showing order id, item count, date, total, payment and order status, with a details link and color badges.
Implement an admin-only details page under admin/orders that reads order and client details from the database. Validate the order id, query orders and user tables, and handle redirects or errors.
Demonstrates building an admin order details page in an ASP.NET Core web app using Razor Pages, with Bootstrap layout showing order and client details, items, and totals.
Administrators learn to update payment and order statuses in an ASP.NET Core Razor Pages web app using Bootstrap modals, select inputs, and tag helpers.
Develop a client order details page in an ASP.NET Core Razor Pages app, authenticate client users, ensure the order belongs to the client, and display order items for review.
Learn to integrate PayPal in an asp.net core razor pages app by creating a PayPal app linked to a business account and storing client id, secret, and api url.
Create a Razor Pages checkout that reads PayPal settings from appsettings, uses TempData to carry delivery address, total amount, and product identifiers, and displays the order summary with PayPal integration.
Integrate PayPal buttons in an ASP.NET Core Razor Pages checkout using the JavaScript SDK, configure the client ID, render the buttons, and handle create, approve, cancel, and error flows.
Define distinct on post methods for create order, complete order, and cancel order on the checkout page, return json containing the PayPal order ID, and disable anti-forgery protection.
Implement on post create order by reading temp data, building a PayPal order with USD amount and purchase units, obtaining a PayPal access token, and returning the order ID.
Implement on post complete order to capture PayPal payment via JSON request using the order ID and access token, handle the response, update states, and clear temp data.
Integrate tinymce as a rich text editor into an ASP.NET web app by replacing a text area, adding Bootstrap scripts, and configuring an API key.
ASP.NET documentation link: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-7.0
Source code:
###################### Program.cs ######################
using Microsoft.AspNetCore.Mvc.Razor;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
// Add services to the container.
builder.Services.AddRazorPages()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
var app = builder.Build();
var supportedCultures = new[] { "en", "fr" };
var localizationOptions = new RequestLocalizationOptions().SetDefaultCulture(supportedCultures[0])
.AddSupportedCultures(supportedCultures)
.AddSupportedUICultures(supportedCultures);
app.UseRequestLocalization(localizationOptions);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
###################### Lang.cshtml.cs ######################
public class LangModel : PageModel
{
public void OnGet()
{
string? culture = Request.Query["culture"];
Console.WriteLine("new selected language: " + culture);
if (culture != null)
{
Response.Cookies.Append(
CookieRequestCultureProvider.DefaultCookieName,
CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)),
new CookieOptions { Expires = DateTimeOffset.UtcNow.AddYears(1) }
);
}
string returnUrl = Request.Headers["Referer"].ToString() ?? "/";
Response.Redirect(returnUrl);
}
}
###################### _ViewImports.cs ######################
@using WebApplication4
@namespace WebApplication4.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
Explore drop-down lists in ASP.NET Core Razor Pages, covering simple and multi-select elements with static and dynamic options, search-enabled and advanced selects, form submission, and model binding.
Publish an ASP.NET Core web application to IIS by enabling IIS, installing the ASP.NET Core bundle, and configuring Windows authentication in IIS application pools to access the database.
Create a product model with id, name, brand, category, price with precision, description, image filename, and created at; apply max length constraints, add a products DbSet, and run migrations.
Seed the product table by inserting 30 rows with name, brand, category, price, description, image file name, and createdat using getdate, then add product images to the public folder.
Enhance your ASP.NET Core Razor Pages app by adding a Bootstrap 5 dropdown in the navbar that links to the admin products index, with home items and product ordering.
Create a product dto model in the models folder that includes user-provided fields name, brand, category, price, description, and the image file, and apply data annotations to mark required fields.
Create a razor page in admin/products to add products by binding a product dto to a post form with multipart/form-data, category select, and image upload, and implement on post method.
Implement the on post method to save a product image on the server and insert the new product into the database, with manual image validation and user feedback.
Learn to save product images on the server by generating a unique timestamped file name, obtaining the web root path, saving the image, and persisting the product to the database.
Implement post method to update a product: validate input, fetch by id, update fields, optionally replace the image file, and save changes with a success redirect.
Implement a Razor Pages search by defining a search field, binding it to the query, and filtering products by name or brand with a Bootstrap search input and preserved pagination.
Create a contact form with entity framework and sql server. Validate inputs with data annotations, handle private file uploads and downloads, implement one-to-many relationships, and list and paginate, delete contacts.
Create two domain models: a contact with its details and a related attachment in a one-to-many relationship via contact id, and add navigation properties to read a contact's attachments.
Create a contact model to store form data, reusing properties from contact and contact dto, with optional IFormFileCollection attachments and validation for required name, email, subject, and 20-character minimum message.
Save the submitted contact form to the database and attachments to a private storage folder using IWebHostEnvironment and the app db context, validating input and showing success or error messages.
Create a razor page for admins to view contact details by reading a contact and its attachments from the database, handling id-based redirects and proper navigation.
Demonstrates a Razor Pages contact details view with a two-column layout, showing id, name, email, phone, subject, date, attachments, and the user message, plus a back link and download links.
Implement a Razor Pages attachment download with an OnGet handler using an attachment id to fetch from the attachments table, build the storage path, and return the file for download.
Create a Razor page to delete a contact from the database and its attachments on the server, then redirect to the contacts list.
Learn how to send transactional emails in an ASP.NET Core Razor Pages app using Bravo (formerly Sendinblue), including API key setup, appsettings configuration, and an email sender service.
Update the shared layout.cshtml to show a new title, window icon, and app name with dynamic year, and refresh the home page with a hero and newest products.
Update the home page hero by replacing index.cshtml with a Bootstrap two-column layout, a bold h1 and paragraph, and a responsive hero image.
Display the four newest products on the home page by querying the db context, sorting by id or created date, and rendering them in a responsive bootstrap grid.
Implement pagination for the products page by displaying six items per page, reading the requested page with a page index, and rendering bootstrap pagination buttons with asp-route-page-index.
Learn to implement a search form on the products page by binding a store search DTO, enabling get submissions, and styling with bootstrap for a sticky, visible form.
Demonstrate adding a sort by dropdown on the products page, binding to the model and auto-submitting on change to sort by newest, price ascending, or price descending.
Learn to display product details in an asp.net core razor pages app by retrieving a product by id and showing its image, price, description, and add to cart button.
This course is for Beginners to ASP.NET having some knowledge of C# or similar programming languages.
In this course, I will show you how to use SqlClient to connect to the database and to execute SQL queries. In addition, I will show you how to implement the traditional authentication using Sessions.
We will use Visual Studio 2022 to connect to the SQL Server and to create the database/tables. So we don’t need to install SSMS (SQL Server Management Studio).
In this course, you will learn:
- How to create an ASP.NET Core Web Application with Razor Pages
- How to create databases and tables using SQL Server and Visual Studio 2022
- How to update the layout of the application
- How to use Session data
- How to use Cookies
- How to validate forms using attributes and model binding
- How to send emails using ASP.NET Core and SendGrid
- How to Implement Authentication and Role based Authorization
- How to reset user password
- How to perform CRUD operations (Create, Read, Update and Delete) on the database using ASP.NET and ADO (no Entity Framework)
- How to perform CRUD operations using Entity Framework
- How to use pagination (Split data on multiple pages)
- How to add advanced search functionalities
- How to upload images to the server
To follow this course, you need to install the following tools
- Visual Studio 2022
- Microsoft SQL Server
Also it is necessary to install two components into Visual Studio: “ASP.NET and web Development” and “.NET Desktop development”