Pro ASP.NET Core 7, MEAP V03 10th Edition Adam Freeman
Pro ASP.NET Core 7, MEAP V03 10th Edition Adam Freeman
Pro ASP.NET Core 7, MEAP V03 10th Edition Adam Freeman
Pro ASP.NET Core 7, MEAP V03 10th Edition Adam Freeman
1. Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.com
Pro ASP.NET Core 7, MEAP V03 10th Edition Adam
Freeman
https://ebookmeta.com/product/pro-asp-net-
core-7-meap-v03-10th-edition-adam-freeman/
OR CLICK HERE
DOWLOAD EBOOK
Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com
2. Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.
Pro ASP.NET Core 7, Tenth Edition (MEAP V03) Adam Freeman
https://ebookmeta.com/product/pro-asp-net-core-7-tenth-edition-
meap-v03-adam-freeman/
ebookmeta.com
Pro ASP NET Core 7 MEAP 10th Edition Adam Freeman
https://ebookmeta.com/product/pro-asp-net-core-7-meap-10th-edition-
adam-freeman/
ebookmeta.com
Pro Entity Framework Core 2 for ASP.NET Core MVC 1st
Edition Adam Freeman
https://ebookmeta.com/product/pro-entity-framework-core-2-for-asp-net-
core-mvc-1st-edition-adam-freeman/
ebookmeta.com
Bright Green Future How Everyday Heroes Are Re Imagining
the Way We Feed Power and Build Our World Gregory Schwartz
https://ebookmeta.com/product/bright-green-future-how-everyday-heroes-
are-re-imagining-the-way-we-feed-power-and-build-our-world-gregory-
schwartz/
ebookmeta.com
3. Snowflake: The Definitive Guide (Final Release) 1st
Edition Joyce Kay Avila
https://ebookmeta.com/product/snowflake-the-definitive-guide-final-
release-1st-edition-joyce-kay-avila/
ebookmeta.com
Rethinking Warfare in the 21st Century 1st Edition Iulian
Chifu
https://ebookmeta.com/product/rethinking-warfare-in-the-21st-
century-1st-edition-iulian-chifu/
ebookmeta.com
Modern Mathematics for 2 2022nd Edition Amit Shrma
https://ebookmeta.com/product/modern-mathematics-for-2-2022nd-edition-
amit-shrma/
ebookmeta.com
Economy 101 Yvette Lapierre
https://ebookmeta.com/product/economy-101-yvette-lapierre/
ebookmeta.com
THE COMPLETE SUPERMARKET MYSTERIES Box Set BOOKS 1 3 three
utterly charming English cozy murder mysteries Rachel Ward
Et El
https://ebookmeta.com/product/the-complete-supermarket-mysteries-box-
set-books-1-3-three-utterly-charming-english-cozy-murder-mysteries-
rachel-ward-et-el/
ebookmeta.com
4. Viking Tattoos Matthew Leigh Embleton
https://ebookmeta.com/product/viking-tattoos-matthew-leigh-embleton/
ebookmeta.com
10. welcome
Dear Reader,
Thank you for purchasing Pro ASP.NET Core 7.
This is the 10th
edition of this book, and the first to be published by
Manning, and I am delighted to be able to do my first MEAP.
Don’t be put off by the size of the book. ASP.NET Core is a big
framework, with lots of features, but I have written this book so that
you can see how everything fits together before diving into the
detail.
In the first part of the book, you will find instructions for getting set
up for ASP.NET Core development, including the creation of a simple
RSVP application, and a primer for important C# language features.
This part of the book includes the SportsStore example, which spans
five chapters, and has become an integral part of almost all my
books. The SportsStore chapters give you a fast-paced overview of
how ASP.NET Core features work together, with pointers to help you
find more detail elsewhere in the book.
The rest of the book describes features in depth, starting with the
way that ASP.NET Core processes HTTP requests, and finishing with
using ASP.NET Core Identity to apply a security policy. There are
endless examples, and every chapter includes a quick reference to
help you find key information as you develop your own projects.
My goal is that you will become familiar with every important
ASP.NET Core feature and be equipped to choose the ones that best
suit your projects. I appreciate feedback and you can raise issues
and ask questions using liveBook Discussion forum or using the
email address given in the book.
11. Yours sincerely,
—Adam Freeman
In this book
Copyright 2023 Manning Publications welcome brief contents 1
Putting ASP.NET Core in context 2 Getting started 3 Your first
ASP.NET Core application 4 Using the development tools 5 Essential
C# features 6 Testing ASP.NET Core applications 7 SportsStore: A
real application 8 SportsStore: Navigation and cart 9 SportsStore:
Completing the cart 10 SportsStore: Administration 11 SportsStore:
Security and deployment 12 Understanding the ASP.NET Core
platform 13 Using URL routing 14 Using dependency injection 15
Using the platform features, part 1 16 Using the platform features,
part 2 17 Working with data 18 Creating the example project 19
Creating RESTful web services 20 Advanced web service features 21
Using controllers with views, part I 22 Using controllers with views,
part II 23 Using Razor pages 24 Using view components 25 Using
tag helpers 26 Using the built-in tag helpers 27 Using the forms tag
helpers 28 Using model binding 29 Using model validation 30 Using
filters 31 Creating form applications 32 Creating the example project
12. 1 Putting ASP.NET Core in
context
This chapter covers
Putting ASP.NET Core in context
Understanding the role of the ASP.NET Core platform
Putting the ASP.NET Core application frameworks in context
Understanding the structure of this book
Getting support when something doesn’t work
ASP.NET Core is Microsoft’s web development platform. The original
ASP.NET was introduced in 2002, and it has been through several
reinventions and reincarnations to become ASP.NET Core 7, which is
the topic of this book.
ASP.NET Core consists of a platform for processing HTTP requests, a
series of principal frameworks for creating applications, and
secondary utility frameworks that provide supporting features, as
illustrated by figure 1.1.
Figure 1.1 The structure of ASP.NET Core
13. Understanding .NET Core, .NET Framework, and .NET
If you have never worked for a large corporation, you might have the
impression that Microsoft is a disciplined organization with a clear
strategy and an army of programmers working together to deliver
complex products like ASP.NET Core.
In reality, Microsoft is a chaotic collection of dysfunctional tribes that
are constantly trying to undermine each other to get prestige and
promotions. Products are released during lulls in the fighting, and
successes are often entirely unexpected. This isn’t unique to
Microsoft—it is true of any large company—but it has a particular
bearing on ASP.NET Core and the naming confusion that Microsoft
has created.
Several years ago, the part of Microsoft responsible for ASP.NET
created its own version of the .NET platform, allowing ASP.NET to be
updated more often than the rest of .NET. ASP.NET Core and .NET
Core were created, allowing cross-platform development, and using a
14. subset of the original .NET APIs, many of which were specific to
Windows. It was a painful transition, but it meant that web
development could evolve independently of the “legacy” Windows-
only development, which would continue under the renamed .NET
Framework.
But no one wants to be in the “legacy” tribe because there is no glory
in keeping the lights on at Microsoft. .NET Core was clearly the future
and, one by one, the.NET groups at Microsoft argued that their
technology and APIs should be part of .NET Core. The .NET Core
APIs were gradually expanded, and the result was an incoherent
mess, with half-hearted attempts to differentiate .NET Core and .NET
Framework and standardize the APIs.
To clean up the mess, Microsoft has merged .NET Core and .NET
Framework into .NET, dropping the Core part of the name. “.NET” is
a name I like to think was chosen on the way out of the office on a
holiday weekend but which I suspect is the result of many months of
heated argument.
The problem with dropping Core from the name is that it cannot be
carried out consistently. The name ASP.NET Core originally denoted
the .NET Core version of ASP.NET, and going back to that name
would be even more confusing.
The result is that even Microsoft can’t decide what name to use. You
will see the term ASP.NET Core in a lot of the developer
documentation—and that’s the name I use in this book—but you will
also see ASP.NET Core in .NET, especially in press releases and
marketing material. It is not clear which name will win out, but until
there is clarity, you should take care to determine whether you are
using .NET Framework, .NET Core, or .NET.
1.1 Understanding the application
frameworks
15. When you start using ASP.NET Core, it can be confusing to find that
there are different application frameworks available. As you will learn,
these frameworks are complementary and solve different problems,
or, for some features, solve the same problems in different ways.
Understanding the relationship between these frameworks means
understanding the changing design patterns that Microsoft has
supported, as I explain in the sections that follow.
Understanding the MVC Framework
The MVC Framework was introduced in the early ASP.NET, long
before .NET Core and the newer .NET were introduced. The original
ASP.NET relied on a development model called Web Pages, which re-
created the experience of writing desktop applications but resulted in
unwieldy web projects that did not scale well. The MVC Framework
was introduced alongside Web Pages with a development model that
embraced the character of HTTP and HTML, rather than trying to hide
it.
MVC stands for Model-View-Controller, which is a design pattern that
describes the shape of an application. The MVC pattern emphasizes
separation of concerns, where areas of functionality are defined
independently, which was an effective antidote to the indistinct
architectures that Web Pages led to.
Early versions of the MVC Framework were built on the ASP.NET
foundations that were originally designed for Web Pages, which led to
some awkward features and workarounds. With the move to .NET
Core, ASP.NET became ASP.NET Core, and the MVC Framework was
rebuilt on an open, extensible, and cross-platform foundation.
The MVC Framework remains an important part of ASP.NET Core, but
the way it is commonly used has changed with the rise of single-page
applications (SPAs). In an SPA, the browser makes a single HTTP
request and receives an HTML document that delivers a rich client,
typically written in a JavaScript client such as Angular or React. The
16. shift to SPAs means that the clean separation that the MVC
Framework was originally intended for is not as important, and the
emphasis placed on following the MVC pattern is no longer essential,
even though the MVC Framework remains useful (and is used to
support SPAs through web services, as described in chapter 19).
Putting patterns in their place
Design patterns provoke strong reactions, as the emails I receive
from readers will testify. A substantial proportion of the messages I
receive are complaints that I have not applied a pattern correctly.
Patterns are just other people’s solutions to the problems they
encountered in other projects. If you find yourself facing the same
problem, understanding how it has been solved before can be
helpful. But that doesn’t mean you have to follow the pattern exactly,
or at all, as long as you understand the consequences. If a pattern is
intended to make projects manageable, for example, and you choose
to deviate from that pattern, then you must accept that your project
may be more difficult to manage. But a pattern followed slavishly can
be worse than no pattern at all, and no pattern is suited to every
project.
My advice is to use patterns freely, adapt them as necessary, and
ignore zealots who confuse patterns with commandments.
Understanding Razor Pages
One drawback of the MVC Framework is that it can require a lot of
preparatory work before an application can start producing content.
Despite its structural problems, one advantage of Web Pages was
that simple applications could be created in a couple of hours.
Razor Pages takes the development ethos of Web Pages and
implements it using the platform features originally developed for the
MVC Framework. Code and content are mixed to form self-contained
17. pages; this re-creates the speed of Web Pages development without
some of the underlying technical problems (although the issue of
scaling up complex projects can still be an issue).
Razor Pages can be used alongside the MVC Framework, which is
how I tend to use them. I write the main parts of the application
using the MVC Framework and use Razor Pages for the secondary
features, such as administration and reporting tools. You can see this
approach in chapters 7–11, where I develop a realistic ASP.NET Core
application called SportsStore.
Understanding Blazor
The rise of JavaScript client-side frameworks can be a barrier for C#
developers, who must learn a different—and somewhat idiosyncratic
—programming language. I have come to love JavaScript, which is as
fluid and expressive as C#. But it takes time and commitment to
become proficient in a new programming language, especially one
that has fundamental differences from C#.
Blazor attempts to bridge this gap by allowing C# to be used to write
client-side applications. There are two versions of Blazor: Blazor
Server and Blazor WebAssembly. Blazor Server relies on a persistent
HTTP connection to the ASP.NET Core server, where the application’s
C# code is executed. Blazor WebAssembly goes one step further and
executes the application’s C# code in the browser. Neither version of
Blazor is suited for all situations, as I explain in chapter 33, but they
both give a sense of direction for the future of ASP.NET Core
development.
1.1.1 Understanding the utility frameworks
Two frameworks are closely associated with ASP.NET Core but are not
used directly to generate HTML content or data. Entity Framework
Core is Microsoft’s object-relational mapping (ORM) framework, which
represents data stored in a relational database as .NET objects. Entity
18. Framework Core can be used in any .NET application, and it is
commonly used to access databases in ASP.NET Core applications.
ASP.NET Core Identity is Microsoft’s authentication and authorization
framework, and it is used to validate user credentials in ASP.NET Core
applications and restrict access to application features.
I describe only the basic features of both frameworks in this book,
focusing on the capabilities required by most ASP.NET Core
applications. But these are both complex frameworks that are too
large to describe in detail in what is already a large book about
ASP.NET Core.
Topics for future editions
I don’t have space in this book to cover every ASP.NET Core, Entity
Framework Core, and ASP.NET Core Identity feature, so I have
focused on those aspects that most projects require. If there are
topics you think I should include in the next edition or in new deep-
dive books, then please send me your suggestions at adam@adam-
freeman.com.
1.1.2 Understanding the ASP.NET Core
platform
The ASP.NET Core platform contains the low-level features required
to receive and process HTTP requests and create responses. There is
an integrated HTTP server, a system of middleware components to
handle requests, and core features that the application frameworks
depend on, such as URL routing and the Razor view engine.
Most of your development time will be spent with the application
frameworks, but effective ASP.NET Core use requires an
understanding of the powerful capabilities that the platform provides,
without which the higher-level frameworks could not function. I
19. demonstrate how the ASP.NET Core platform works in detail in part 2
of this book and explain how the features it provides underpin every
aspect of ASP.NET Core development.
I have not described two notable platform features in this book:
SignalR and gRPC. SignalR is used to create low-latency
communication channels between applications. It provides the
foundation for the Blazor Server framework that I describe in part 4
of this book, but SignalR is rarely used directly, and there are better
alternatives for those few projects that need low-latency messaging,
such as Azure Event Grid or Azure Service Bus.
gRPC is an emerging standard for cross-platform remote procedure
calls (RPCs) over HTTP that was originally created by Google (the g in
gRPC) and offers efficiency and scalability benefits. gRPC may be the
future standard for web services, but it cannot be used in web
applications because it requires low-level control of the HTTP
messages that it sends, which browsers do not allow. (There is a
browser library that allows gRPC to be used via a proxy server, but
that undermines the benefits of using gRPC.) Until gRPC can be used
in the browser, its inclusion in ASP.NET Core is of interest only for
projects that use it for communication between back-end servers,
such as in microservices development. I may cover gRPC in future
editions of this book but not until it can be used in the browser.
1.2 Understanding this book
To get the most from this book, you should be familiar with the basics
of web development, understand how HTML and CSS work, and have
a working knowledge of C#. Don’t worry if you haven’t done any
client-side development, such as JavaScript. The emphasis in this
book is on C# and ASP.NET Core, and you will be able to pick up
everything you need to know as you progress through the chapters.
In chapter 5, I summarize the most important C# features for
ASP.NET Core development.
20. 1.2.1 What software do I need to follow the
examples?
You need a code editor (either Visual Studio or Visual Studio Code),
the .NET Core Software Development Kit, and SQL Server LocalDB.
All are available for use from Microsoft without charge, and chapter 2
contains instructions for installing everything you need.
1.2.2 What platform do I need to follow the
examples?
This book is written for Windows. I used Windows 10 Pro, but any
version of Windows supported by Visual Studio, Visual Studio Code,
and .NET Core should work. ASP.NET Core is supported on other
platforms, but the examples in this book rely on the SQL Server
LocalDB feature, which is specific to Windows. You can contact me at
[email protected] if you are trying to use another platform,
and I will give you some general pointers for adapting the examples,
albeit with the caveat that I won’t be able to provide detailed help if
you get stuck.
1.2.3 What if I have problems following the
examples?
The first thing to do is to go back to the start of the chapter and
begin again. Most problems are caused by missing a step or not fully
following a listing. Pay close attention to the emphasis in code
listings, which highlights the changes that are required.
Next, check the errata/corrections list, which is included in the book’s
GitHub repository. Technical books are complex, and mistakes are
inevitable, despite my best efforts and those of my editors. Check the
errata list for the list of known errors and instructions to resolve
them.
21. If you still have problems, then download the project for the chapter
you are reading from the book’s GitHub repository,
https://github.com/manningbooks/pro-asp.net-core-7, and compare it
to your project. I create the code for the GitHub repository by
working through each chapter, so you should have the same files with
the same contents in your project.
If you still can’t get the examples working, then you can contact me
at [email protected] for help. Please make it clear in your email
which book you are reading and which chapter/example is causing
the problem. Please remember that I get a lot of emails and that I
may not respond immediately.
1.2.4 What if I find an error in the book?
You can report errors to me by email at [email protected],
although I ask that you first check the errata/corrections list for this
book, which you can find in the book’s GitHub repository at
https://github.com/manningbooks/pro-asp.net-core-7, in case it has
already been reported.
I add errors that are likely to cause confusion to readers, especially
problems with example code, to the errata/corrections file on the
GitHub repository, with a grateful acknowledgment to the first reader
who reported them. I also publish a typos list, which contains less
serious issues, which usually means errors in the text surrounding
examples that are unlikely to prevent a reader from following or
understanding the examples.
Errata bounty
Manning has agreed to give a free ebook to readers who are the first
to report errors that make it onto the GitHub errata list for this book,
which is for serious issues that will disrupt a reader’s progress.
Readers can select any Manning ebook, not just my books.
22. This is an entirely discretionary and experimental program.
Discretionary means that only I decide which errors are listed in the
errata and which reader is the first to make a report. Experimental
means Manning may decide not to give away any more books at any
time for any reason. There are no appeals, and this is not a promise
or a contract or any kind of formal offer or competition. Or, put
another way, this is a nice and informal way to say thank you and to
encourage readers to report mistakes that I have missed when
writing this book.
1.2.5 What does this book cover?
I have tried to cover the features that will be required by most
ASP.NET Core projects. This book is split into four parts, each of
which covers a set of related topics.
Part 1: Introducing ASP.NET Core
This part of the book introduces ASP.NET Core. In addition to setting
up your development environment and creating your first application,
you’ll learn about the most important C# features for ASP.NET Core
development and how to use the ASP.NET Core development tools.
Most of part 1 is given over to the development of a project called
SportsStore, through which I show you a realistic development
process from inception to deployment, touching on all the main
features of ASP.NET Core and showing how they fit together—
something that can be lost in the deep-dive chapters in the rest of
the book.
Part 2: The ASP.NET Core platform
The chapters in this part of the book describe the key features of the
ASP.NET Core platform. I explain how HTTP requests are processed,
how to create and use middleware components, how to create
routes, how to define and consume services, and how to work with
23. Entity Framework Core. These chapters explain the foundations of
ASP.NET Core, and understanding them is essential for effective
ASP.NET Core development.
Part 3: ASP.NET Core applications
The chapters in this part of the book explain how to create different
types of applications, including RESTful web services and HTML
applications using controllers and Razor Pages. These chapters also
describe the features that make it easy to generate HTML, including
the views, view components, and tag helpers.
Part 4: Advanced ASP.NET Core features
The final part of the book explains how to create applications using
Blazor Server, how to use the experimental Blazor WebAssembly, and
how to authenticate users and authorize access using ASP.NET Core
Identity.
1.2.6 What doesn’t this book cover?
This book doesn’t cover basic web development topics, such as HTML
and CSS, and doesn’t teach basic C# (although chapter 5 does
describe C# features useful for ASP.NET Core development that may
not be familiar to developers using older versions of .NET).
As much as I like to dive into the details in my books, not every
ASP.NET Core feature is useful in mainstream development, and I
have to keep my books to a printable size. When I decide to omit a
feature, it is because I don’t think it is important or because the same
outcome can be achieved using a technique that I do cover.
As noted earlier, I have not described the ASP.NET Core support for
SignalR and gRPC, and I note other features in later chapters that I
don’t describe, either because they are not broadly applicable or
24. because there are better alternatives available. In each case, I
explain why I have omitted a description and provide a reference to
the Microsoft documentation for that topic.
1.2.7 How do I contact the author?
You can email me at [email protected]. It has been a few
years since I first published an email address in my books. I wasn’t
entirely sure that it was a good idea, but I am glad that I did it. I
have received emails from around the world, from readers working or
studying in every industry, and—for the most part anyway—the
emails are positive, polite, and a pleasure to receive.
I try to reply promptly, but I get a lot of email, and sometimes I get a
backlog, especially when I have my head down trying to finish writing
a book. I always try to help readers who are stuck with an example in
the book, although I ask that you follow the steps described earlier in
this chapter before contacting me.
While I welcome reader emails, there are some common questions
for which the answers will always be no. I am afraid that I won’t
write the code for your new startup, help you with your college
assignment, get involved in your development team’s design dispute,
or teach you how to program.
1.2.8 What if I really enjoyed this book?
Please email me at [email protected] and let me know. It is
always a delight to hear from a happy reader, and I appreciate the
time it takes to send those emails. Writing these books can be
difficult, and those emails provide essential motivation to persist at
an activity that can sometimes feel impossible.
1.2.9 What if this book has made me angry and
I want to complain?
25. You can still email me at [email protected], and I will still try to
help you. Bear in mind that I can only help if you explain what the
problem is and what you would like me to do about it. You should
understand that sometimes the only outcome is to accept I am not
the writer for you and that we will have closure only when you return
this book and select another. I’ll give careful thought to whatever has
upset you, but after 25 years of writing books, I have come to
understand that not everyone enjoys reading the books I like to
write.
1.3 Summary
ASP.NET Core is a cross-platform framework for creating web
applications.
The ASP.NET Core platform is a powerful foundation on which
application frameworks have been built.
The MVC Framework was the original ASP.NET Core framework.
It is powerful and flexible but takes time to prepare.
The Razor Pages framework is a newer addition, which requires
less initial preparation but can be more difficult to manage in
complex projects.
Blazor is a framework that allows client-side applications to be
written in C#, rather than JavaScript. There are versions of
Blazor that execute the C# code within the ASP.NET Core server
and entirely within the browser.
26. 2 Getting started
This chapter covers
Installing the code editor and SDK required for ASP.NET Core
development
Creating a simple ASP.NET Core project
Responding to HTTP requests using a combination of code and
markup
The best way to appreciate a software development framework is to
jump right in and use it. In this chapter, I explain how to prepare for
ASP.NET Core development and how to create and run an ASP.NET
Core application.
2.1 Choosing a code editor
Microsoft provides a choice of tools for ASP.NET Core development:
Visual Studio and Visual Studio Code. Visual Studio is the traditional
development environment for .NET applications, and it offers an
enormous range of tools and features for developing all sorts of
applications. But it can be resource-hungry and slow, and some of
the features are so determined to be helpful they get in the way of
development.
Visual Studio Code is a lightweight alternative that doesn’t have the
bells and whistles of Visual Studio but is perfectly capable of handling
ASP.NET Core development.
All the examples in this book include instructions for both editors, and
both Visual Studio and Visual Studio Code can be used without
charge, so you can use whichever suits your development style.
27. If you are new to .NET development, then start with Visual Studio. It
provides more structured support for creating the different types of
files used in ASP.NET Core development, which will help ensure you
get the expected results from the code examples.
Note
This book describes ASP.NET Core development for Windows. It is
possible to develop and run ASP.NET Core applications on Linux and
macOS, but most readers use Windows, and that is what I have
chosen to focus on. Almost all the examples in this book rely on
LocalDB, which is a Windows-only feature provided by SQL Server
that is not available on other platforms. If you want to follow this
book on another platform, then you can contact me using the email
address in chapter 1, and I will try to help you get started.
2.1.1 Installing Visual Studio
ASP.NET Core 7 requires Visual Studio 2022. I use the free Visual
Studio 2022 Community Edition, which can be downloaded from
www.visualstudio.com. Run the installer, and you will see the prompt
shown in figure 2.1.
Figure 2.1 Starting the Visual Studio installer
28. Click the Continue button, and the installer will download the
installation files, as shown in figure 2.2.
Figure 2.2 Downloading the Visual Studio installer files
When the installer files have been downloaded, you will be presented
with a set of installation options, grouped into workloads. Ensure that
the “ASP.NET and web development” workload is checked, as shown
in figure 2.3.
Figure 2.3 Selecting the workload
29. Select the “Individual components” section at the top of the window
and ensure the SQL Server Express 2019 LocalDB option is checked,
as shown in figure 2.4. This is the database component that I will be
using to store data in later chapters.
30. Figure 2.4 Ensuring LocalDB is installed
Click the Install button, and the files required for the selected
workload will be downloaded and installed. To complete the
installation, a reboot may be required.
Note
You must also install the SDK, as described in the following section.
Installing the .NET SDK
The Visual Studio installer will install the .NET Software Development
Kit (SDK), but it may not install the version required for the examples
in this book. Go to https://dotnet.microsoft.com/download/dotnet-
core/7.0 and download the installer for version 7.0.0 of the .NET SDK,
which is the long-term support release at the time of writing. Run the
installer; once the installation is complete, open a new PowerShell
command prompt from the Windows Start menu and run the
31. command shown in listing 2.1, which displays a list of the installed
.NET SDKs.
Listing 2.1 Listing the Installed SDKs
dotnet --list-sdks
Here is the output from a fresh installation on a Windows machine
that has not been used for .NET:
7.0.100 [C:Program Filesdotnetsdk]
If you have been working with different versions of .NET, you may
see a longer list, like this one:
5.0.100 [C:Program Filesdotnetsdk]
6.0.100 [C:Program Filesdotnetsdk]
6.0.113 [C:Program Filesdotnetsdk]
6.0.202 [C:Program Filesdotnetsdk]
6.0.203 [C:Program Filesdotnetsdk]
7.0.100 [C:Program Filesdotnetsdk]
Regardless of how many entries there are, you must ensure there is
one for the 7.0.1xx version, where the last two digits may differ.
2.1.2 Installing Visual Studio Code
If you have chosen to use Visual Studio Code, download the installer
from https://code.visualstudio.com. No specific version is required,
and you should select the current stable build. Run the installer and
ensure you check the Add to PATH option, as shown in figure 2.5.
Figure 2.5 Configuring the Visual Studio Code installation
32. Installing the .NET SDK
The Visual Studio Code installer does not include the .NET SDK,
which must be installed separately. Go to
https://dotnet.microsoft.com/download/dotnet-core/7.0 and
download the installer for version 7.0.0 of the .NET SDK, which is the
long-term support release at the time of writing. Run the installer;
once the installation is complete, open a new PowerShell command
prompt from the Windows Start menu and run the command shown
in listing 2.2, which displays a list of the installed .NET SDKs.
Listing 2.2 Listing the Installed SDKs
dotnet --list-sdks
Here is the output from a fresh installation on a Windows machine
that has not been used for .NET:
7.0.100 [C:Program Filesdotnetsdk]
33. If you have been working with different versions of .NET, you may
see a longer list, like this one:
5.0.100 [C:Program Filesdotnetsdk]
6.0.100 [C:Program Filesdotnetsdk]
6.0.113 [C:Program Filesdotnetsdk]
6.0.202 [C:Program Filesdotnetsdk]
6.0.203 [C:Program Filesdotnetsdk]
7.0.100 [C:Program Filesdotnetsdk]
Regardless of how many entries there are, you must ensure there is
one for the 7.0.1xx version, where the last two digits may differ.
Installing SQL Server LocalDB
The database examples in this book require LocalDB, which is a zero-
configuration version of SQL Server that can be installed as part of
the SQL Server Express edition, which is available for use without
charge from https://www.microsoft.com/en-in/sql-server/sql-server-
downloads. Download and run the Express edition installer and select
the Custom option, as shown in figure 2.6.
Figure 2.6 Selecting the installation option for SQL Server
34. Once you have selected the Custom option, you will be prompted to
select a download location for the installation files. Click the Install
button, and the download will begin.
When prompted, select the option to create a new SQL Server
installation, as shown in figure 2.7.
Figure 2.7 Selecting an installation option
35. Work through the installation process, selecting the default options as
they are presented. When you reach the Feature Selection page,
ensure that the LocalDB option is checked, as shown in figure 8. (You
may want to uncheck the Machine Learning Services option, which is
not used in this book and takes a long time to download and install.)
Figure 2.8 Selecting the LocalDB feature
36. On the Instance Configuration page, select the “Default instance”
option, as shown in figure 9.
Figure 2.9 Configuring the database
37. Continue to work through the installation process, selecting the
default values, and complete the installation.
2.2 Creating an ASP.NET Core
project
The most direct way to create a project is to use the command line.
Open a new PowerShell command prompt from the Windows Start
menu, navigate to the folder where you want to create your ASP.NET
Core projects, and run the commands shown in listing 2.3.
Tip
You can download the example project for this chapter—and for all
the other chapters in this book—from
https://github.com/manningbooks/pro-asp.net-core-7. See chapter 1
for how to get help if you have problems running the examples.
Listing 2.3 Creating a new project
38. dotnet new globaljson --sdk-version 7.0.100 --output
FirstProject
dotnet new mvc --no-https --output FirstProject --framework
net7.0
dotnet new sln -o FirstProject
dotnet sln FirstProject add FirstProject
The first command creates a folder named FirstProject and adds to
it a file named global.json, which specifies the version of .NET that
the project will use; this ensures you get the expected results when
following the examples. The second command creates a new
ASP.NET Core project. The .NET SDK includes a range of templates
for starting new projects, and the mvc template is one of the options
available for ASP.NET Core applications. This project template creates
a project that is configured for the MVC Framework, which is one of
the application types supported by ASP.NET Core. Don’t be
intimidated by the idea of choosing a framework, and don’t worry if
you have not heard of MVC—by the end of the book, you will
understand the features that each offers and how they fit together.
The remaining commands create a solution file, which allows multiple
projects to be used together.
Note
This is one of a small number of chapters in which I use a project
template that contains placeholder content. I don’t like using
predefined project templates because they encourage developers to
treat important features, such as authentication, as black boxes. My
goal in this book is to give you the knowledge to understand and
manage every aspect of your ASP.NET Core applications, and that’s
why I start with an empty ASP.NET Core project. This chapter is
about getting started quickly, for which the mvc template is well-
suited.
2.2.1 Opening the project using Visual Studio
39. Start Visual Studio and click the “Open a project or solution” button,
as shown in figure 2.10.
Figure 2.10 Opening the ASP.NET Core project
Navigate to the FirstProject folder, select the FirstProject.sln file,
and click the Open button. Visual Studio will open the project and
display its contents in the Solution Explorer window, as shown in
figure 2.11. The files in the project were created by the project
template.
Figure 2.11 Opening the project in Visual Studio
40. 2.2.2 Opening the project with Visual Studio
Code
Start Visual Studio Code and select File > Open Folder. Navigate to
the FirstProject folder and click the Select Folder button. Visual
Studio Code will open the project and display its contents in the
Explorer pane, as shown in figure 2.12. (The default dark theme used
in Visual Studio Code doesn’t show well on the page, so I have
changed to the light theme for the screenshots in this book.)
Figure 2.12 Opening the project in Visual Studio Code
41. Additional configuration is required the first time you open a .NET
project in Visual Studio Code. The first step is to click the Program.cs
file in the Explorer pane. This will trigger a prompt from Visual Studio
Code to install the features required for C# development, as shown in
figure 2.13. If you have not opened a C# project before, you will see
a prompt that offers to install the required assets, also shown in
figure 2.13.
Figure 2.13 Installing Visual Studio Code C# features
42. Click the Install or Yes button, as appropriate, and Visual Studio Code
will download and install the features required for .NET projects.
2.3 Running the ASP.NET Core
application
Visual Studio and Visual Studio Code can both run projects directly,
but I use the command line tools throughout this book because they
are more reliable and work more consistently, helping to ensure you
get the expected results from the examples.
When the project is created, a file named launchSettings.json is
created in the Properties folder, and it is this file that determines
which HTTP port ASP.NET Core will use to listen for HTTP requests.
Open this file in your chosen editor and change the ports in the URLs
it contains to 5000, as shown in listing 2.4.
Listing 2.4 Setting the Port in the launchSettings.json File in the
Properties Folder
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5000",
"sslPort": 0
43. }
},
"profiles": {
"FirstProject": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
It is only the URL in the profiles section that affects the .NET
command-line tools, but I have changed both of them to avoid any
problems. Open a new PowerShell command prompt from the
Windows Start menu; navigate to the FirstProject project folder,
which is the folder that contains the FirstProject.csproj file; and
run the command shown in listing 2.5.
Listing 2.5 Starting the example application
dotnet run
The dotnet run command compiles and starts the project. Once the
application has started, open a new browser window and request
http://localhost:5000, which will produce the response shown in
figure 2.14.
Figure 2.14 Running the example project
44. When you are finished, use Control+C to stop the ASP.NET Core
application.
2.3.1 Understanding endpoints
In an ASP.NET Core application, incoming requests are handled by
endpoints. The endpoint that produced the response in figure 2.14 is
an action, which is a method that is written in C#. An action is
defined in a controller, which is a C# class that is derived from the
Microsoft.AspNetCore.Mvc.Controller class, the built-in controller
base class.
Each public method defined by a controller is an action, which means
you can invoke the action method to handle an HTTP request. The
convention in ASP.NET Core projects is to put controller classes in a
folder named Controllers, which was created by the template used
to set up the project.
The project template added a controller to the Controllers folder to
help jump-start development. The controller is defined in the class
file named HomeController.cs. Controller classes contain a name
46. boards of the Parisian stages, though, through want of patronage or
opportunity, they very often never even so much as entered the
capital) quite equal to its rendition, she having a clear distinct diction
which she knew thoroughly well how to accompany with suitable
gesture. Also, which caused some remark even amongst this
unemotional audience, she bore a striking likeness to the highbred
dame who was the authoress of the drama. The woman was tall and
exquisitely shaped; her primrose-coloured hair--coloured thus, either
by art and design, or nature--curled in crisp curls about her head;
her eyes were blue as corn-flowers. Wherefore, as they gazed on
her, there ran a suppressed titter through that audience, a whispered
word or so passed, more than one head turned, and more than one
pair of eyes rested inquiringly on Diane Grignan de Poissy sitting
some row or so of chairs back from the platform. And there were
some whose eyes sought the countenance of le Duc Desparre and
observed that his face, although blank as a mask, showed signs of
aroused interest; that his eyes were fixed eagerly on the wandering
mummer who enacted Célie.
"'Tis thee," whispered Agénor to his aunt. "'Tis thee!"
"Yes. It is I," she whispered back. In solemn diction, the woman
unfolded her story. The story of an innocent girl betrayed into a
mock marriage, a fictitious priest, desertion followed by death, and
her own determination to secure the child and to rear it, and, some
day, to use that child as a means whereby to wreak vengeance on
the betrayer because he was such in a double capacity. He had
sworn his love to Célie, to herself, as well as to the unfortunate
woman now lying dead; he had deceived them both. Only the dead
woman was poor; she was rich. Rich enough, at least, to provide in
some way for that child, to keep it alive until the time came for
producing it. "As I swear to do," Célie cried in rhyme, this being the
last speech, or tag, of the prologue, "even though I wait for years.
For years." Then she called on Phœbus and many other heathen
divinities so dear to the hearts of the French dramatists, to hear her
register her vow. And, thus, the prologue ended amidst a buzz from
47. the audience, loud calls for Célie, for de Crébillon, for the author.
Expectancy had been aroused, the most useful thing of all others,
perhaps, to which a prologue could be put. De Crébillon led on the
blue-eyed, golden-haired actress, and she, standing before the most
exalted audience which had ever witnessed her efforts, considered
that her fortune was as good as made. Henceforth, farewell, she
hoped, to acting in barns and hastily-erected booths in provincial
towns and villages, to the homage of country boors and simple
country gentlemen. She saw before her . . . what matters what she
saw! In all that audience none, except a few of the younger and
most impressionable of the men, thought of the handsome stroller;
all desired to know what the drama itself would bring forth.
For none doubted now (since they knew full well from de
Crébillon's whispered hints and suggestive glances who the author
was) that Desparre was the man pointed at as the betrayer of the
woman who had been seen stretched in the garret. All remembered
that, for years, even during the life of the old king, his name had
been coupled with that of the Marquise. And they remembered that
she, who was once looked upon as the certain Duchesse Desparre of
the future, had never become his wife; that instead, he had meant
to wed with a woman who had emerged none knew whence except
that it was from the gutters of the streets--from beneath a gambler's
roof; and that even such a one as this had jilted him! Jilted him who
sat there now, still as a statue, white as one, too. Looking like death
itself!
What were they about to see? A denunciation of this man by his
abandoned child to that intended bride born of the gutter, a
denunciation so fierce and terrible that even she, that creature of
nothingness, shrank from him as something so base--so scabreux,
as they termed it in their whispers--that she dared not share his
illustrious name! Was that what was now to be depicted before
them? Was that the true reason for the scandal with which all Paris
had rung since the cruel months of winter; of which people still
spoke apart and in subdued murmurs? Was the abandoned orphan,
48. or rather her representative, to speak her denunciation on that
platform? Was that woman of the people to fly from him before their
eyes? Was the Duc Desparre to be held up before them here, on this
summer day, in the true colours which all knew him to possess, but
which all, because he was of their own patrician order, endeavoured
to forget that he thus possessed?
If so, then Diane Grignan de Poissy's vengeance was, indeed, an
awful one! If so, then God shield them from having their own secrets
fall into her possession, from having her vengeance aroused against
them, too!
As had been ever since the days of Hardy, of Corneille, of Moliere,
their attention was now drawn to the fact that the actual play was
about to commence by three thumps upon the stage from a club,
and, once more, they settled down to the enjoyment of the
spectacle; the buzz amongst them ceasing as again the curtain was
drawn back. They prepared for the denunciation! Yet, still, in their
last whispers to each other ere silence set in, they asked how that
denunciation was to take effect? There were but two female
characters, Célie, the protectress, Cidalise, the orphan. Where then
was the character of the woman to whom the man was to be
denounced; the woman who should represent before them that
creature of the lower orders who, in actual fact and life, had last
winter fled from Desparre--the blanched figure sitting before them--
sooner than become his wife and a duchess?
Perhaps, after all, they thought and said, they had been
mistaken--perhaps, after all, it was not a true representation of
Desparre's degradation which was about to be offered to them!
Perhaps they had misjudged, overrated, the vengeance of Diane!
Well! they would soon see now. The curtain was withdrawn, the
scene was exposed, and it represented a pretty salon adorned for a
festivity--a betrothal.
49. The play began.
CHAPTER XIX
"THE ABANDONED ORPHAN"
DRAMA
The usual guests who figure at stage weddings had assembled in
the salon. Evidently, the audience whispered, one to another, it was
a marriage contract, at least, which was about to be signed--or,
perhaps, an assemblage of relatives at the bride's house ere setting
forth to the church. No doubt of that, they thought, else why the
love-knots at ladies' wrists and breasts--quite clean and fresh
because, somehow, the poor strolling players who represented high-
born dames had been provided with them by the giver of the
entertainment--and why, also, had the gentlemen got on the best
suits which the baggage waggon of their troupe contained?
Wherefore, after seeing all this, the actual high-born dames and
men of ancient family in the audience gave many a sidelong glance
at each other, while the former's eyes frequently flashed leering
looks over their enamelled cheeks and from beneath their painted
eyelashes and eyebrows. For all recalled that, in the real drama
which had happened in Paris in the winter months--the real drama
over which Baron and Destouches and Poinsinet (who should never
have been an author, since he was born almost a gentleman), and
other grinning devils of the pen, had made such bitter mockery in
verse and prose--in that real drama, a marriage, renounced and
broken, had formed the main incident. Recalling all this, they settled
50. down well into their seats, eager and excited as to what was to
come.
Enter amongst the guests, Célie. The handsome woman was
made up to look a little older now. Yet, "the deuce confound me!"
said the venerable Marquise de Champfleury, a lady who, fifty years
before, had been renowned for her bonnes fortunes in the Royal
circle, "the deuce confound me! she resembles Diane more than
ever." Which was true, and was, perhaps, made more so by the fact
that the woman was now wearing a costly dress which Diane
Grignan de Poissy had herself worn more than once at Eaux St. Fer
before all her friends, but which she had now bestowed upon the
wandering actress. The latter was, indeed, so like Diane, that again
and again the revered marquise uttered her oaths as she regarded
her.
To Célie there entered next Cidalise, young, slender, pretty, yet--
because sometimes the troupe were starving and had naught to eat
but that which was flung to them in charity, or a supper of broken
victuals given them by an innkeeper in return for a song or
performance before a handful of provincial shopkeepers--thin, and
out of condition. Nevertheless, she could deliver her lines well, and
speak as clearly as Charlotte Lenoir had done, or as La Gautier did
now--and would have become a leading actress, indeed might
become one yet, if she could only get a foothold in Paris.
In short, sharp sentences, such as the French dramatists loved to
intersperse with the terribly long monologues which, in other places,
they put into the mouths of their characters, Célie asked her if she
was resolved to carry out her contract and marry this man, this
Prince, who desired her for his wife? Yes, Cidalise replied, yes. Not
because she loved him, but because her origin was obscure, her
present surroundings revolting. Was not her uncle a gambler! At this
there was a movement amongst the audience; many exquisitely
painted fans were fluttered, a rustle of silk and satin and brocade
was perceptible. And, also, eyes gleamed into other eyes again, but
51. none spoke. Even the old Marquise de Champfleury swore no more.
The aged trifler had become interested, a novelty which had not
occurred to her--unless in connection with herself and her food and
her health--for a long time.
Yet, because when all is said, these were ladies and gentlemen,
not one stole a glance in the direction of Monsieur le Duc.
Had they done so they would have seen that he sat motionless in
his seat, with his eyes half closed, yet glittering, as they gazed at the
two women on the stage.
Two more figures were now upon the scene. His Highness, the
Prince, the bridegroom predestinate, and also the uncle of Cidalise;
the first called Cléon, Prince de Fourbignac, the second, Dorante.
They loved such names as these, did those old French dramatists.
Yet what was there about the man who played the Prince which
awoke recollections in the minds of all the audience of another man
they had once seen or known who was not the Duc Desparre, but
someone very like him? How--how was that likeness produced? The
vagabond, the stroller who enacted the illustrious personage, was a
big, hectoring fellow, with a short-clipped, jet black moustache; an
individual who looked more accustomed to the guardroom than a
salon, to a spadroon clanking against his thigh--perhaps sticking out
half a foot through its worn-out scabbard--than to a clouded cane
which he now wielded, even though in a salon. His clothes, too--they
were the best that could be found in the frowsy, hair-covered trunk
which carried the costumes of the "first gentleman" of the troupe--
seemed more fitted to some bully or sharper than to an exquisite.
So, too, did his expressions, his "Health, belle comtesse!" to one
high-born (stage) lady, his "Rasade" to another whose glass touched
his as she wished him felicity; so, too, did his vulgar heartiness to
all.
"A Prince!" the real aristocrats in front muttered to themselves
and each other, yet remembered that the words he uttered must for
52. sure have been put into his mouth either by the authoress, or her
collaborateur, De Crébillon. Only, why and wherefore? And still they
were puzzled, since many of them could recall in far back days some
fellow very much like the creature who was now strutting about the
stage and kicking a footman here and there, slapping the bare
shoulders of female guests, and giving low winks to his male friends.
There was some art in this, they muttered; some recollection
which it was intended to evoke. Whom had they ever known like
this? What fellow who, for some particular reason, had been
admitted to their august society--a society in which, to do them
justice, they behaved admirably and with exquisite grace so long as
their actions were public, no matter how much they atoned for that
behaviour by extremely questionable conduct in private?
Then they remembered all, memory being aroused by none other
than the respected Marquise de Champfleury.
"Me damne!" she whispered, changing her form of exclamation
somewhat--probably for fear of being monotonous. "Me damne!
does no one recall our friend when a beggarly captain on the
frontier? Hein! he was the second, heir then, wherefore we
permitted his presence sometimes. Yet, only sometimes, God be
praised! Had he not been an heir, our lackeys should have kicked
him down the street. You remember; you, Fifine, and you, Finette?
Heaven knows you are both old enough to do so!"
After which the amiable aristocrat ceased her pleasing prattle, and
attended to the development of the drama before them.
They were all doing that now, eagerly, absorbingly, and even
more especially so since the fine memory of the old Marquise had
recalled to them, or most of them, the time when Desparre stamped
about their salons roughly, and, because he was the second heir to
the dukedom and almost sure to succeed to it some day, treated
them all to a great deal of what they termed privately in disgust, "his
53. guardroom manners." And, in remembering, they thought what good
fortune it was for Diane (if it was not the outcome of astute
selection) to have secured this rough fellow to personate the man
she was undoubtedly bent on exposing--the man who now sat
staring at the stage with his face as set as a mask, and as
expressionless.
Meanwhile, the play went on. The signing of the contract which,
all recognised now, was the ceremony to be performed, was at
hand. First came the bridegroom, who--having ceased his tavern
buffooneries--so becoming to a Prince! and in the distribution of
which he had included Cidalise, who, with well-acted horror, shrank
from him every time he approached her--drew near the table at
which the notary and his clerk sat, and, having slapped the former
on the back, affixed his signature with a great deal of gesticulation,
and then handed the quill with ostentatious politeness to his future
Princess.
"Sign, dear idol," he whispered in a stage whisper, "sign. I await
with eagerness the right to call thee mine." Only he marred
somewhat these affecting words by winking at another girl who
stood by Cidalise.
On either side of that Iphigenia were grouped now Célie and
Dorante--an old grisly actor this, round shouldered and ill-favoured,
who had forgotten to shave himself that morning, or who, perhaps,
imagined that, as he represented a Parisian gambler, it was a touch
of nature to go thus unclean--Cléon being of course next to Cidalise.
And to her, Célie spoke clearly, so clearly that her voice was heard by
everyone of the audience present in the salon of The Garland as she
said "Sign, Cidalise." Then she stood with her large blue eyes fixed
full on Cléon, while the expression in them told the spectators as
plainly as words could have done that the great moment was at
hand, that the dénouement was coming.
"Sign," she said again.
54. Taking the pen, the girl signed, repeating in stage fashion the
letters of the name "Cidalise," so that the audience, who could not
see the characters, should understand that they were being written
down.
"So," exclaimed Célie, her eyes still on Cléon, "So, Cidalise.
Continue."
"D. O. R.," murmured the bride as she pretended to write again,
when, suddenly, breaking in upon hers was heard the voice of the
leading actress. "No! Not that. If you sign further you must use
another name." Then, turning to Cléon she hissed rapidly:
"Lâche! You abandoned one woman and deserted another. My
time has come."
Aroused thoroughly, the audience bent forward in their chairs.
The Marquise de Champfleury drew a quick breath, but cursed no
more. Agénor Grignan de Poissy felt his aunt's hand tighten
convulsively on his. Now, not one of the painted patricians glanced
at the other; all eyes were on the stage, except one pair--those of
Diane--and they were fixed on Desparre!
"What must I sign?" whispered Cidalise, trembling, and playing
her part as the audience said afterwards, à ravir. "What? What?"
"Demand of thy uncle--uncle, mon Dieu! Demand of Dorante.
Speak, Dorante."
"Thy real name," replied Dorante slowly, effectively, "is De
Fourbignac."
"Thou canst not marry him," and now the woman who
represented Célie was superb, as, with finger extended and eyes
ablaze, she pointed at Cléon, (she got to Paris at last and became
the leading lady at the Odéon!). "He is thy father. Even as he
deserted me, so, too, he deserted thy mother, leaving her to die of
55. starvation. Villain! maraud!" she exclaimed, turning on Cléon. "What
did I promise thee? Thus I fulfil my vow."
"And thus I avenge myself," cried Cléon, tugging at his rapier.
"Thus, traitress----"
But the actor did not finish his speech. From outside the wall of
the salon was heard ringing the great bell of The Garland; the bell
which was a signal to all who resided at the inn that now was the
time when the noblesse, in contradistinction to those of the
commercial world, repaired to the wells of Eaux St. Fer, there to take
their glass of those unutterably filthy, but health-giving waters.
Perhaps it was an arranged thing; arranged by the vengeful Diane,
or the spiteful De Crébillon. Perhaps, too, it was arranged that, as
the bell ceased to ring, the old Comte de la Ruffardière, a man who
was of the very highest position even among so fashionable an
audience as that assembled there, should rise from his chair and say,
in a voice exquisitely sweet and silvery:
"Mesdames et Messieurs,--you hear that bell. Alas, that it should--
although we are desolated in obeying it--that it should be able to call
us away from this most ravishing drama. Yet, my dear friends, we
have our healths, our most precious healths, to consult. If we miss
our revivifying glass what shall become of us? Madame," addressing
the representative of Célie, "Monsieur," to Cléon, "Mademoiselle," to
Cidalise--his manners were of a truth perfect--not for nothing had he
handed the Grand Monarch his shirt for forty-two nights in every
year (by royal appointment), and watched his august master's
deportment both in public and private--"we are penetrated, we are
in despair, at having to depart ere this most exciting play is at an
end. A play, my faith! it is a tragedy of the first order. Yet, yet, it
must be so. We are all invalids--sufferers. Alas! the waters the
waters! We must partake of the waters!"
Then he bowed again, solemnly to each actress, in a friendly way
to the representatives of Cléon and Dorante, comprehensively to all.
56. And, strange to say, not one of those gifted Thespians seemed at all
surprised, nor in the least offended, at the departure of the
audience, which was now taking place rapidly. On the contrary, the
shrinking, persecuted Cidalise, that distinguished heroine and once-
about-to-be sacrificed one, tapped him lightly on his aged cheek
with her bridal fan as he stepped on to the foot-high stage, and
whispered, "be still, vieux farceur," while Célie regarded him with a
mocking smile in her blue eyes. Nor did Cléon refuse a fat purse
which, surreptitiously, the old courtier dropped into his hand, but,
instead, murmured his thanks again and again.
The audience had indeed departed now amidst rustlings of silks
and satins, the click-clack of light dress swords upon the parquet
floor, and the sharp tap of high heels. Diane, with her nephew, had
slipped out even as De la Ruffardière commenced his oration;
scarcely any were left when he had concluded it and his withered old
cheek had received the accolade of Cidalise. And, it was strange! but
not one had looked at--in solemn truth, all had avoided looking at--
the only person who seemed to make no attempt to move.
Desparre!
Desparre, who sat on and on in his seat, motionless as ever, and
always stone, marble white; his eyes glaring through their drooping
lids at the little stage on which the battered old courtier was
whispering his compliments.
Presently however, the latter turned and descended the foot-high
platform, casting his eyes,--for him, timidly and, undoubtedly,
furtively--at the silent, motionless figure sitting there. Then he
turned round to the actors and actresses who, themselves, had
observed Desparre, while, in a totally different tone from that in
which he had previously addressed them, he said:
"Begone. Quit the stage. Your parts are played. And," he
muttered to himself, "played with sufficient effect."
57. As they obeyed his orders--he watching them depart from the
scene of what was undoubtedly their triumph (never before had
those wandering comedians achieved such a success--in more ways
than one), he went over slowly to where the Duke sat and touched
him gently on the shoulder. The withered, battered old roué, who
had known the secrets and intrigues of the most intriguing court that
ever existed in Europe, had still something left that did duty for a
heart.
"Come, Desparre. Come," he said. "The company has broken up.
It is time to--to--to take the waters."
But Monsieur le Duc, sitting there, his eyes still fixed on the stage,
made him no answer, though his lips moved once, and once he
turned those eyes and gazed at the old Chevalier by his side.
"Come, Desparre," the other repeated. "If not the waters, at least
to your apartments. Come."
Then, old and feeble though he was, he placed his hands under
Desparre's shoulders and endeavoured to assist him to rise.
CHAPTER XX
"THE WAY TO DUSTY DEATH"
"If," said Lolive, the Duke's valet, to himself later that day, "he
would speak, would say something--not sit there like one dead, I
could endure it very well. But, mon Dieu! he makes me shudder!"
58. It was not strange that the shivering servant should feel afraid,
though he scarce knew of what. One feels not afraid of the actual
dead--they can harm us no more, even if they have been able to do
so in life!--unless one is a coward as this valet was; yet, still, the
brave are sometimes appalled at the resemblance of death which, on
occasions, those who are yet alive are forced to assume, owing to
some strange stroke that has attacked either heart or nerve or brain.
And such a stroke as this, subtle and intangible, was the one which
had fallen upon Desparre.
He was alive, Lolive knew; he could move, he felt sure; almost,
too, was he confident that his master could speak if he chose. Yet
neither did he move nor speak. Instead, he did nothing but sit there
immobile, before the great cheval glass, staring into it, his hands
lying listless in his lap, his face colourless and his lips almost as
much so.
Once, the valet had made as though he was about to commence
undressing Desparre after having previously turned down the bed
and prepared it for his reception, but, although the latter had not
spoken, he had done what was to the menial's mind more terrifying.
He had snarled at him as an ill-conditioned cur snarls at those who
go near him, while showing, too, like a dog, his discoloured teeth
with, over them, the lips drawn back and, thereby, exhibiting his
almost white gums. And with, too, his eyes glistening horribly.
Then the man had withdrawn from close vicinity to that master
and had busied himself about the room, while doing anything rather
than again approach the chair in which the stricken form was
seated. Also, he lit the wax candles in all the branches about the
room; on the dressing table, over the bed, and in girandoles placed
at even distances on the walls, while receiving, as it seemed to him
some comfort from the light and brightness he had now produced.
For some reason, which, as with his other fears, he could not have
explained, he feared to be alone in the gathering darkness with that
living statue.
59. Summoning up again, however, his courage, he approached once
more his master and pointed to the latter's feet and to the diamond-
buckled shoes upon them, then whispered timorously that it would
be well if Monsieur would at least allow those shoes to be removed.
"Doubtless Monsieur was tired," he said; "doubtless also it would
relieve Monsieur."
But again he drew back trembling. Once more that hateful snarl
came on Desparre's face, and once more there was the drawn-back
lip. "What," the fellow asked himself, "what was he to do?" Then,
suddenly he bethought him of the fashionable doctors from Paris of
whom Eaux St. Fer was full; he would go and fetch one, if not two of
them. Thereby, at least, he would be acquitted of failing in his duty if
the Duke died to-night, which, judging by his present state, seemed
more than likely.
Thinking thus, he let his eyes wander round the room, while
meditating as he did so. Near to the bedside was a locked cupboard
in which he had placed, on their arrival, a large sum of money, a
sum doubly sufficient to pay any expenses Desparre might incur
during his course of waters; in a valise, bestowed in the same
cupboard, was a small coffer full of jewellery of considerable value.
And, upon the walls of the lodging, was the costly tapestry which, in
accordance with most noblemen and all wealthy persons in those
days, Desparre had brought with him, so that the often enough bare
and scanty lodgings to be found at such resorts as Eaux St. Fer
might be rendered pleasant and agreeable to the eyes. This he too
regarded, remembering as well the costly suits his master had with
him; the wigs, each costing over a thousand livres, the lace for
sleeves and breast and for the steinkirks and other cravats, and the
ivory-hilted Court sword in which was a great diamond. He recalled
all the costly things the room contained.
"If he should die to-night," he muttered inwardly--"to-night. None
would know what he brought with him and what he left behind.
None, but I. No other living soul knows what he possessed. He
60. hated all his kinsmen and kinswomen. None know. I will go seek the
doctors; yet, ere I do so--I will--will place these things out of sight.
They must not see too much."
Then the knave began moving about the room, "arranging"
things, while, even as he did so, he recalled a cabaret in Paris where
heavy gambling went on as well as eating and drinking, which was
for sale for two thousand crowns. If he had but that sum! And--and-
-Desparre might die to-night! Wherefore, his eyes stole sideways
towards the spectral figure seated there--powerless, or almost so.
He might die to-night! Might die to-night! Well! Why not? Why
might he not die to-night? The doctor--the leading one from Paris--
should visit him. Yes, he should do that. He knew that doctor; he
had seen him called in before to gouty, or paralysed, or dropsical
men and women whose servant he himself had once been. And he
knew the fashionable physician's formula--the cheering words,
accompanied, however, by a slightly doubting phrase; the safe-
guarding of his own reputation by a hint to others that--"all the
same"--"nevertheless"--"it might be--he could not say. If there were
any relatives they should be warned--not alarmed, oh, no! only
warned," and so forth. Well! the doctor should come to see the
Duke. Doubtless he would say some such thing before himself and
the landlord, who, he would take care, should also be in the room.
That would be sufficient. If the Duke did die to-night suddenly, as he
might very well do--as he would do--why then he, Lolive, was safe.
The doctor's words would have saved him.
He was sure now that Monsieur would die to-night. Quite sure. So
sure that he knew nothing could save the Duke. He would die to-
night; he even knew the time it would happen; between one and
two of the clock, when every soul in Eaux St. Fer would be wrapped
in sleep, even to the servants. Then, about that hour--perhaps
nearer two than one--the Duke would die. And the cabaret, the
disguised gambling hell, would be his in a month's----
61. "Lolive," uttered a voice from behind him. "Lolive!"
The man started; stopped in what he was doing; then dropped a
dressing case with almost a crash on to the shelf of a wardrobe, in
which he was placing the box and its contents, and withdrew his
own head from the inside of the great bureau. He scarcely dared,
however, to turn that head round to the spot whence the voice
issued, since he knew that he was white to the lips; since he felt
that he was trembling a little. Yet--he must do it--it had to be done--
it was his master's voice.
Therefore he turned, gazing with startled eyes at Desparre who
was now sitting up more firmly in his chair, and saw that some
change had come to him, that he had regained speech as well as
sense, that he would not die, could not by any chance be made to
die, that night. The possession of the cabaret was as far off as ever
now!
"Ah, Monsieur, the Virgin be praised," he exclaimed fawningly and
with a smile of satisfaction, as he ran forward to where Desparre sat,
still rigid, though not so rigid as before. "Monsieur is better. What
happiness! Monsieur will go to bed now."
While, even as he spoke, he regained courage; confidence. Sick
men had died before now in their beds, in their sleep. Such things
had been often heard of: they might--would, doubtless--be heard of
again.
His master spoke once more, the voice, harsh, bitter, raucous, yet
distinct.
"Malotru!" Desparre said, while, as he did so, his eyes gleamed
dully at the other, "you thought I was dead, or dying. Eh, dog? Well!
it is not so. Go--descend at once. Order my travelling carriage. We
depart to-night, in an hour--for--Marseilles."
"For Marseilles?"
62. "Ask no questions. Go. Hangdog I Go, I say. And come not back
until you bring me news that the carriage is prepared. Go, beast!"
"The horses, Monsieur; the coachman! He sleeps----"
But there the valet stopped. Desparre's eyes were on him. He was
afraid. Therefore he went, murmuring that Monsieur should be
obeyed.
Left alone, Desparre still sat on for some moments in his chair,
listless and motionless. Then, slowly, he raised himself by using his
hands upon the arms of the chair as levers; he stood erect upon his
feet. He tried his legs, too, and found he could walk, though heavily
and with a feeling as if he had two senseless columns of lead
beneath him instead of limbs. Still, he could walk.
"The second time," he muttered to himself, as he did so. "The
second time. What--what did the physician tell me? What? That, if
the first stroke did not kill neither would the second, but that--that
the third was certain, unfailing. If that could not be avoided, all was
lost. All! No longer any hope. This is the second, when will the third
come? When? Perhaps--when I stand face to face with her again.
With Cidalise! My God! When she blasts me to death with one look.
Cidalise! Laure!"
He resumed his seat, resumed, too, his dejected musings.
"It was well done. Fool that I am never to have remembered that
Diane was implacable. Cidalise! Ha! I recollect. It was my pet name
for the woman I left behind in Paris when hastily summoned away. I
loved that woman. She--she--Diane must have known--have taken
the child, have reared it. And I should have married her--my own
child! Oh, God! that such awful, impious vengeance could be
conceived. That, having found out how, all unknowing, I loved the
girl, she--she--she--that merciless devil--would have stood by and let
me marry her--my child. My own child. The child of Cidalise."
63. Again he sat back in his chair. To an onlooker it would have
seemed as though it was still a statue sitting there before him. Yet
he was musing always and revolving horrible matter in his mind.
"Baulked thus," he reflected; "she evolved this scheme of revenge
to expose me to all. To tell me, too, that I have consigned my own
child to a living death, to exile in a savage land, to the chain gang.
And, I have gloated over it, not knowing. Not knowing! I have
pictured the woman whom I deemed to have outraged me as
trudging those weary leagues with the carcan round her neck, the
chains about her limbs. And she was my own child! My own child!
My own child!"
Again he paused, thinking now of what lay before him. Of what
he had to do. What was it? Yes, he remembered his orders for the
carriage to be prepared. He had to hasten to Marseilles at once, as
fast as that coach (known as a "berceuse"), as that luxurious
sleeping carriage could be got there, and then to intercept the
cordon of women who were to be deported; to find her, to save her.
And--and--and, if they had already reached that city and left for New
France--if they had sailed--what to do next? What? Why, to follow in
the first vessel that went. To save her! To save her! To save her if
she had not fallen dead by the roadside, as he knew, as all France
knew, the women and the men did often enough fall dead on those
awful journeys.
But if he found her; if God had spared her; if she still lived! What
then? What had he then to do? To stand before her whom he had
most unrighteously sent to so cruel a doom, to acknowledge himself
so vile, so deep a villain that life was too good for such as he; yet,
also, to purge himself in her eyes of one, of two, crimes. To prove to
her that he knew not that her mother, ere dying, had ever borne him
a child; to prove to her that he had never dreamt, when he
proposed to marry her, that he was so near committing the most
hideous crime that could be perpetrated. And afterwards--
afterwards--then--well, then, she might curse him as he stood before
64. her, or the third stroke that he knew would--must come--might come
then. What mattered; nothing could matter then. He would have
saved her. That was enough.
Why did not the menial come to tell him the berceuse was ready--
the great cumbersome form of carriage which Guise had invented
fifty years before, so that one might sleep in their beds even while
they travelled on and on through day and night, and also take their
meals therein--the commodious carriage which had been built for
himself in exact imitation of that possessed by the present young
Duc de Richelieu et Fronsac.
Young Richelieu! What a scoundrelly ruffian he was, he found
himself meditating; what a villain, what a seducer; how he would
have revelled in the idea of a man marrying his own daughter after
leaving the mother to starve, how----. He broke off in these musings
to curse Lolive and all his pack of pampered servants, coachmen and
footmen, who were snoring still in their beds, and to curse himself;
to wonder when the third stroke would come and how: to wonder
also if it would be when he stood before his wronged daughter. To
muse if he would fall dead, writhing at her feet--to----
Lolive re-entered the room. The berceuse was ready, the horses
got out of the stables. Would Monsieur have all his goods packed
and taken with him, also his jewellery, or--or should he wake the
landlord and confide everything to him until--until Monsieur's return?
Only, Lolive thought to himself, Monsieur might, in truth, never
return. He was ill, very ill; he might die on the road to Marseilles. He
hoped that, at least (though he did not say so), the Duke would not
take the money and the jewellery with him. Thus, he could find it
later!
"Take," said Desparre, his eyes glinting hideously, as Lolive
thought, "take all that is of small compass and of value. Give it to
me, I will bestow the money and jewellery where it will be safe in
the carriage. Give it to me."
65. With a smothered oath, the valet did as he was bidden, Desparre
placing the jewellery in the pockets of his vast travelling cloak, and
the money about him, and bidding Lolive pack the clothes, the wigs
and the swords at once, and swiftly. And the pistols; they, too,
should go.
"There are highwaymen, brigands, upon the road, Lolive," he
muttered, fixing the valet with his eye. "Thieves everywhere. It may
befall that I shall have to shoot a thief on the way. I had best be
armed--ready."
Wherefore he took the box containing his silver-hilted pistols upon
his knee, and, with the lid up, sat regarding the man as he hastily
packed all that was to accompany them on the journey to Marseilles.
"My God!" the fellow muttered, "he makes me tremble. Can this
man, half alive, half dead, divine my thoughts?"
The boxes were packed at last with their changes of linen and
clothes; once more Desparre was left alone. Lolive was despatched
to arouse the landlord and to inform him that Monsieur had to
depart at once for Marseilles on important matters, but that his room
was to be retained for him and his furniture and other things taken
proper care of. And the valet was also bidden to say that the Duke
did not require the presence of the landlord to see him depart. The
reason whereof being that Desparre felt sure that the man knew as
well as all in Eaux St. Fer knew what had befallen him that day; and
how a play had been produced by a vengeful woman for the sole
purpose of holding him up to the derision, the execration, of all who
were in the little watering-place, nobility and others, as well as the
"refuse" who had not been admitted to the representation but were
aware of what had happened.
Everyone knew! He could never return here, nor to Paris. If he
found his child, if he saved her, then--then he must go away
somewhere, or--or, perhaps, then the third stroke would fall. Well, so
66. best. He would be better dead. He could not live long; he
understood by the doctor's manner that his doom was pronounced,
assured. Better dead!
Upon the night air, up from the street below, he could hear the
rumble of the berceuse on the stones as it approached the door of
the house where he lodged; he could also hear the horses shaking
their harness, and the mutterings of the coachman and the footman
at being thus dragged forth from their beds at night.
It was time to go--time for Lolive and the footman to come up
with the carrying chair, which he used now when stairs had to be
either ascended or descended, not so much because he could not
walk as because he did not care to do so. He could have got down
those stairs to-night, he knew, even after this second shock, this
further and last warning of his impending end--only he would not.
These menials, these dogs of his, would have heard from Lolive of
that stroke--they would be peering curiously at him out of their low,
cunning eyes to see whether he were worse or not.
Therefore, he let them carry him down and place him on his bed
in the sleeping carriage, while all the time but one thought occupied
his mind.
That thought--what he would find at the end of his journey, and
whether he would find his child alive or dead?
CHAPTER XXI
A NIGHT RIDE