
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.
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.
Create a Razor Pages details page that reads a message ID from the query, fetches data from the messages table, and displays all fields.
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.
Add two tables: a users table with id, email (unique), and role, plus a password reset table with email and token, created at.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 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.
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.
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”