Full Download Creating ASP NET Core Web Applications Proven Approaches to Application Design and Development 1st Edition Dirk Strauss PDF DOCX
Full Download Creating ASP NET Core Web Applications Proven Approaches to Application Design and Development 1st Edition Dirk Strauss PDF DOCX
com
https://textbookfull.com/product/creating-asp-net-core-web-
applications-proven-approaches-to-application-design-and-
development-1st-edition-dirk-strauss/
OR CLICK BUTTON
DOWNLOAD NOW
Pro ASP NET Core MVC Develop cloud ready web applications
using Microsoft s latest framework ASP NET Core MVC Sixth
Edition Adam Freeman
https://textbookfull.com/product/pro-asp-net-core-mvc-develop-cloud-
ready-web-applications-using-microsoft-s-latest-framework-asp-net-
core-mvc-sixth-edition-adam-freeman/
textboxfull.com
https://textbookfull.com/product/ultimate-asp-net-core-web-api-2nd-
edition-marinko-spasojevic/
textboxfull.com
Dirk Strauss
Creating ASP.NET Core Web Applications: Proven Approaches to
Application Design and Development
Dirk Strauss
Uitenhage, South Africa
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 285
viii
About the Author
Dirk Strauss is a software developer from South Africa
who has been writing code since 2003. He has extensive
experience in SYSPRO, with C# and web development being
his main focus. He studied at the Nelson Mandela University,
where he wrote software on a part-time basis to gain a better
understanding of the technology. He remains passionate
about writing code and imparting what he learns to others.
ix
About the Technical Reviewer
Carsten Thomsen is a back-end developer primarily but
working with smaller front-end bits as well. He has authored
and reviewed a number of books and created numerous
Microsoft Learning courses, all to do with software
development. He works as a freelancer/contractor in various
countries in Europe; Azure, Visual Studio, Azure DevOps,
and GitHub are some of the tools he works with. Being an
exceptional troubleshooter, asking the right questions,
including the less logical ones, in a most logical to least
logical fashion, he also enjoys working with architecture,
research, analysis, development, testing, and bug fixing.
Carsten is a very good communicator with great mentoring and team-lead skills, and
great skills in researching and presenting new material.
xi
Acknowledgments
I would like to thank my wife and kids for their support during the writing of this book.
I love you always!
xiii
Introduction
.NET Core has given .NET developers a lot to think about. Some developers have
embraced the technology, while others have taken a wait-and-see approach. Whatever
approach you are taking, .NET Core is without a doubt here to stay.
Developing web applications is also not one of the easiest things to do. I’ve always
wanted to write a book on developing web applications, but to do it in a way that is very
structured and takes the reader on a journey of discovery.
Creating ASP.NET Core Web Applications is my attempt at that book. I always try to
take the point of view that the book I’m writing is a reference book for my bookshelf.
With this in mind, I, therefore, tried to cover a wide set of topics.
As with all projects, Chapter 1 starts with creating your project and using the .NET
CLI. We have a look at adding Razor pages and also how to configure the application
using the appsettings.json file. I then create a dummy data service, which is used to get
the application up and running with test data. This test data is designed in such a way
that it can easily be swapped out at a later stage (and I show you how to do this).
Chapter 2 takes a look at the process of creating models, model binding, tag helpers,
working with a query string, and page routes. To illustrate these concepts, Chapter 2
shows you how to implement a search form. This allows us to search for data, view the
details, and add in logic to handle bad requests.
Chapter 3 illustrates the concepts of editing the data, displaying validation errors,
and modifying the data access service to suit our needs. I also discuss the differences
between singleton, scoped, and transient lifetime registration for services.
EF Core and SQL Server become the focus in the next chapter. Chapter 4 shows
you how to install Entity Framework Core, define your connection strings, what
database migrations are, and how to use them. We will also be implementing a new
data access service and changing the data access service registration from the test
data to the SQL data.
xv
Introduction
Moving to the front end next, we have a look at working with Razor pages in Chapter 5.
Here, we will look at what sections are and how they benefit you as a developer. We take a
closer look at _ViewImports and _ViewStart files. I also show you how to create your own tag
helper, how to work with partial views, and, finally, how to work with ViewComponents.
Staying front end, we have a look at adding client-side logic in Chapter 6. I show
you how to separate production scripts from development scripts, use SCSS to generate
CSS, how SCSS works, and the different features you can use to create CSS with SCSS, as
well as work with Chrome Developer Tools. This is, in my opinion, crucial for any web
developer to know.
With Chapter 7, we will take a look at what middleware is. This is a very important
chapter and one that will require some explaining. We have a look at some of the built-
in middleware components, but also how to create a custom middleware component
if the built-in middleware components don’t suit your needs. After creating a custom
middleware component, we will have a look at logging in ASP.NET Core. Logging is a big
subject, but this book tries to cover the basics.
Finally, Chapter 8 will take you through getting your web application ready for
deployment and finally publishing your web application and hooking it up to a SQL
Server database. I hope that you will enjoy this book as much as I enjoyed writing it.
xvi
CHAPTER 1
I will assume that you have already installed .NET Core onto your machine. The
web application we will be creating will use .NET Core 3.1. If you have not installed
.NET Core, you can do so by visiting this link: https://dotnet.microsoft.
com/download.
Because we are working with .NET Core which is cross-platform, I will also show you
how to create an application using the Command Prompt later in this section.
1
© Dirk Strauss 2021
D. Strauss, Creating ASP.NET Core Web Applications, https://doi.org/10.1007/978-1-4842-6828-5_1
Chapter 1 Creating and Setting Up Your Project
For now, let us start by creating a new project in Visual Studio. From the file menu,
click New Project. This will display the Create a new project screen as seen in Figure 1-1.
The Create a new project screen that allows you to select the correct project template
lists all the available templates included in Visual Studio. In our case, we will be using
the ASP.NET Core Web Application template.
If you are used to working in previous versions of Visual Studio, you will notice that
this screen has been vastly improved. You can search for templates by typing a template
name into the search text box or by holding down Alt+S.
You can also filter project templates from the drop-downs on the form. You will
notice that you can filter by language, platform, and project type.
Clicking the Next button will take you to the Configure your new project screen as
seen in Figure 1-2.
2
Chapter 1 Creating and Setting Up Your Project
Give the project a suitable name. For this book, we will simply call the project
VideoStore and specify a location to create the project in. When you have done this, click
the Create button.
You will now be taken to a second screen as seen in Figure 1-3 where you can select
the specific type of template that you want to use.
3
Chapter 1 Creating and Setting Up Your Project
It is here that we can specify the version of .NET Core that we want to use. In this
example, we are selecting .NET Core 3.1. We can then tell Visual Studio that we want to
create a basic web application. Just leave the rest of the settings at their default values
and click the Create button.
4
Chapter 1 Creating and Setting Up Your Project
After the project has been created in Visual Studio, you can hit Ctrl+F5 to run the
web application. This will run your project without the debugger attached and display
the web application in your browser as seen in Figure 1-4.
You will notice that the web application is running on port 44398 in this example,
but your port will most likely be different. By default, this web application includes some
basic features such as a Home page as well as a Privacy page.
It is from here that we will start to flesh out our web application and add more
features and functionality to it.
5
Chapter 1 Creating and Setting Up Your Project
Once you have installed .NET Core on your Mac, Linux, or Windows machine, you
should be able to simply open your Terminal, Shell, or Command Prompt and type the
dotnet command as seen in Figure 1-5.
To see more of the commands available with dotnet, you can type dotnet -h in the
Command Prompt. If you typed in dotnet new, you would see all the available project
templates listed in your Command Prompt window.
These templates, along with the short name associated with that specific template,
are listed in the following table.
6
Chapter 1 Creating and Setting Up Your Project
7
Chapter 1 Creating and Setting Up Your Project
You will notice that to create an ASP.NET Web Application, we need to specify the
short name webapp with the new command.
As seen in Figure 1-6, typing in the command dotnet new webapp will create the
ASP.NET Web Application inside the current directory.
Figure 1-6. Creating the Web App via the .NET CLI
8
Chapter 1 Creating and Setting Up Your Project
If you had to compare the project created via the .NET CLI with the one created in
Visual Studio, you will see that these are identical.
The .NET CLI offers a fantastic, quick, and cross-platform way of creating
applications.
This means that when I view the Privacy page in the web application, ASP.NET Core
is busy rendering the Privacy.cshtml page. You will also notice that the cshtml extension
is not required in the URL as seen in Figure 1-8.
9
Chapter 1 Creating and Setting Up Your Project
You will also notice that when you make your browser window smaller, the menu
collapses into the hamburger icon. This is made possible by Bootstrap, which is included
in the project by default.
If you now click your Privacy.cshtml page in the Solution Explorer, you will see the
code as listed in Code Listing 1-1.
With your web application running without the debugger attached, if you click the
hamburger menu icon, you will see that we have just two pages listed which are Home
and Privacy.
10
Chapter 1 Creating and Setting Up Your Project
Looking at Figure 1-9 and comparing that to the code in Code Listing 1-1, you might
be wondering where the code is for the navigation.
The answer lies in a special Razor page called a Layout page. Swing back to your
Solution Explorer, and expand the Shared folder under the Pages folder. There you will
see a page called _Layout.cshtml as seen in Figure 1-10.
11
Chapter 1 Creating and Setting Up Your Project
It is this Layout page that renders everything within the web application's <head>
tags, things such as links to all the required stylesheets, as well as <body> tags that
include a <header> section containing the navigation menu. The code for the navigation
menu is listed in Code Listing 1-2.
12
Chapter 1 Creating and Setting Up Your Project
Go ahead and add another menu item called Videos, by adding a new list item to the
unordered list as seen in Code Listing 1-3.
You will notice that the asp-page tag helper specifies Videos/List which tells my
web application that inside a folder called Videos is a page that will display a list of
videos. Running your web application again, you will see that the Videos menu item has
been added to the navigation menu (Figure 1-11).
13
Chapter 1 Creating and Setting Up Your Project
If you click the Videos menu item, the link will not navigate anywhere. This is
because we have not yet added the required Razor page. As shown in Figure 1-12, add a
new folder under the Pages folder in your Solution Explorer.
14
Chapter 1 Creating and Setting Up Your Project
Next, right-click the Videos folder, and add a new Razor page called List to the
folder. This can be done from the context menu or from the Add New Item screen as
shown in Figure 1-13.
15
Chapter 1 Creating and Setting Up Your Project
Once the List.cshtml page has been added, you will notice that Visual Studio has
added a second page (Figure 1-14) called List.cshtml.cs. The List.cshtml file is
essentially my Razor page containing the @page directive (Code Listing 1-4).
@page
@model VideoStore.Pages.Videos.ListModel
@{
}
Furthermore, the Razor page also specifies a model with the @model directive. It
is telling .NET Core that the model that contains video information is contained in an
object of type ListModel.
16
Random documents with unrelated
content Scribd suggests to you:
such as appear are usually goddesses or accessory persons in
mythical scenes; but with the gradual change to subjects taken from
every-day life in the later sixth and the early fifth century, we begin to
see women about their usual occupations, or in groups talking with
each other or with men. Much of the later Athenian pottery is
decorated with charming scenes from the life of women, showing
them with their children, at their toilet, busy with embroidery, or
playing with pets. The younger ones seem to have enjoyed some
games which we have relegated to childhood, such as spinning tops
(see fig. 53). On the marriage-vases we see the bride being dressed
by her friends and servants, or receiving presents on the day after
the wedding, the traditional occasion for the presentation of gifts.
Two of these vases are in Case B in the Fifth Room (fig. 45), and a
perfume vase in Case Q is decorated with a similar scene. The usual
presents seem to have been bands and ribbons for the hair,
perfumes, jewelry, and pets, especially birds.
V
CHILDREN AND EDUCATION
CASES 2 AND 3
Greek and Roman children played with toys much like those of the
present day, but they were simple and inexpensive. Rattles for
babies were made of terracotta with a few pebbles enclosed (Case
3, middle shelf). An interesting toy for a small child is the terracotta
horse from Cyprus with large jars in its panniers such as those
carried by real horses for taking provisions to and from market (Case
2, top shelf, fig. 49). Carts were favorite playthings; a small oinochoë
in Case 3 shows a boy driving two goats harnessed to a chariot, and
on a white lekythos painted for a child’s grave (Case F in the Fifth
Room), a little boy is going to Charon’s boat for his journey over the
Styx, drawing his toy cart (fig. 50). Of course, Greek and Roman
children kept house with their dolls, and charming miniature vases
were made for them, some for the doll’s table and others for her
toilet and wedding. These vases, which are decorated with scenes of
children at play, were given, it is thought, as presents on a festival
day called Choes, “Jugs.” A number of different types are in Case G
in the Fifth Room.
Dolls were made of wax and clay. The two seated terracotta dolls
without joints in Case L in the Seventh Room were found in graves
at Tarentum in Southern Italy. Another made of bone has jointed
arms and could easily be dressed (Case 3, tail-piece, p. 46). These
dolls were originally painted in bright colors, which have been
destroyed by time.
FIG. 50. TOMB LEKYTHOS.
CHILD DRAWING A CART
At about six years of age Greek boys were sent to school, while
the girls remained at home to learn from their mothers how to spin
and weave, and to read a little and keep accounts. Their education
was of the simplest kind and ceased very early.
The first school to which a boy went was that of the letter-teacher,
who taught reading, writing, and simple arithmetic. A kylix in Case 3
(see head-band, p. 40) is decorated with figures of schoolboys, one
of whom holds a roll of manuscript, and another a writing tablet.
These tablets were thin pieces of wood covered with wax and
fastened together with cords (fig. 56). A pointed stylus (fig. 54) was
used for writing, the blunt end being turned around when it was
necessary to erase by smoothing the wax[1]. After three or four years
in the letter-school the boys went to the music teacher, who taught
them to sing and to play the lyre, and in connection with the music
they learned many selections from the great poets. Training in the
palaistra or wrestling-school was begun very early, and was usually
continued until the boy was old enough to be called into the military
service of the state. These lessons will be described in the section
on athletics, as the sports of the palaistra were in general the same
as those of the men’s gymnasium. In addition to the subjects already
mentioned, many boys, during the fifth century and later, studied
geometry, rhetoric, and philosophy.
The woman’s Doric chiton of this time may be seen in the statue of
Eirene, No. 15 in the Sculpture Gallery (fig. 61), and it is worn
without a girdle by the young girl on a gravestone (No. 21, fig. 63).
Here the open side shows plainly. A drawing of Zeus on a krater on
the bottom of Case O in the Fourth Room, and a young hunter on a
krater on the left side of the first shelf show the man’s chiton (fig. 67).
The Ionic chiton is illustrated by the statue of a goddess, No. 19 in
the Sculpture Gallery. Metal buttons to represent the sleeve
fastenings were inserted in the marble.
FIG. 63. DORIC CHITON
WITHOUT GIRDLE
FIG. 64. LADY IN HIMATION
AND HAT
FIG. 65. LADY IN HIMATION
FIG. 66. MAN IN RIDING-CLOAK
AND HAT
Shoes were of two principal types: sandals with straps, and high
shoes or boots for hunting and traveling. The Greeks valued finely
made shoes, and dandies sometimes invented new fashions which
were called by their names, as “Alkibiades shoes.” A terracotta foot
from Cyprus wearing a sandal and another painted black are on the
middle shelf of Case 2. On a krater in Case O in the Fourth Room
Hermes wears high laced boots with a tongue rising above the laces,
and a stamnos on the bottom of Case E shows the hunter Eos in
boots. The bronze statuette of the philosopher Hermarchos in the
Seventh Room wears sandals which are worked out in detail (fig.
69), and an idea of the thickness of the soles may be gained from
those worn by the woman on a stele, No. 4 in the Sculpture Gallery.
The number and arrangement of the straps which held the sandal in
place were various and they were sometimes broad enough to form
what was practically a shoe. Boots were at times made with the leg-
covering composed of leather bands resembling modern puttees.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com