0% found this document useful (0 votes)
18 views

Download ebooks file Exploring Blazor: Creating Server-side and Client-side Applications in .NET 7 2nd Edition Taurius Litvinavicius all chapters

The document promotes the ebook 'Exploring Blazor: Creating Server-side and Client-side Applications in .NET 7' by Taurius Litvinavicius, available for download on ebookmeta.com. It provides an overview of Blazor, a framework for developing web applications using C#, and discusses its features, including server-side and client-side types. The book emphasizes practical learning through exercises and sample code to enhance the reader's understanding of Blazor.

Uploaded by

qaalibshemy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Download ebooks file Exploring Blazor: Creating Server-side and Client-side Applications in .NET 7 2nd Edition Taurius Litvinavicius all chapters

The document promotes the ebook 'Exploring Blazor: Creating Server-side and Client-side Applications in .NET 7' by Taurius Litvinavicius, available for download on ebookmeta.com. It provides an overview of Blazor, a framework for developing web applications using C#, and discusses its features, including server-side and client-side types. The book emphasizes practical learning through exercises and sample code to enhance the reader's understanding of Blazor.

Uploaded by

qaalibshemy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

Exploring Blazor: Creating Server-side and Client-


side Applications in .NET 7 2nd Edition Taurius
Litvinavicius

https://ebookmeta.com/product/exploring-blazor-creating-
server-side-and-client-side-applications-in-net-7-2nd-
edition-taurius-litvinavicius/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Exploring Blazor: Creating Hosted, Server-side, and


Client-side Applications with C# 1st Edition Taurius
Litvinavicius
https://ebookmeta.com/product/exploring-blazor-creating-hosted-server-
side-and-client-side-applications-with-c-1st-edition-taurius-
litvinavicius/
ebookmeta.com

SharePoint Development Understanding the Server Side


Object Model SSOM Mujthaba Hassan

https://ebookmeta.com/product/sharepoint-development-understanding-
the-server-side-object-model-ssom-mujthaba-hassan/

ebookmeta.com

Microsoft Blazor: Building Web Applications in .NET -


Second Edition Peter Himschoot

https://ebookmeta.com/product/microsoft-blazor-building-web-
applications-in-net-second-edition-peter-himschoot/

ebookmeta.com

Beaches and Betrayal Dune House Mystery 22 Cindy Bell

https://ebookmeta.com/product/beaches-and-betrayal-dune-house-
mystery-22-cindy-bell/

ebookmeta.com
Strategic Management : A Competitive Advantage Approach —
Concepts and Cases, 17th Global Edition Fred R. David

https://ebookmeta.com/product/strategic-management-a-competitive-
advantage-approach-concepts-and-cases-17th-global-edition-fred-r-
david/
ebookmeta.com

How Scholars Write 1st Edition Aaron Ritzenberg

https://ebookmeta.com/product/how-scholars-write-1st-edition-aaron-
ritzenberg/

ebookmeta.com

Spatially Independent Martingales Intersections and


Applications 1st Edition Pablo Shmerkin

https://ebookmeta.com/product/spatially-independent-martingales-
intersections-and-applications-1st-edition-pablo-shmerkin/

ebookmeta.com

RELATIVISM AND HUMAN RIGHTS: A Theory of Pluralist


Universalism, 2nd 2nd Edition Claudio Corradetti

https://ebookmeta.com/product/relativism-and-human-rights-a-theory-of-
pluralist-universalism-2nd-2nd-edition-claudio-corradetti/

ebookmeta.com

Moon 52 Things to Do in Chicago Local Spots Outdoor


Recreation Getaways 1st Edition Rosalind Cummings-Yeates

https://ebookmeta.com/product/moon-52-things-to-do-in-chicago-local-
spots-outdoor-recreation-getaways-1st-edition-rosalind-cummings-
yeates/
ebookmeta.com
Tensors for Data Processing: Theory, Methods, and
Applications 1st Edition Yipeng Liu (Ed.)

https://ebookmeta.com/product/tensors-for-data-processing-theory-
methods-and-applications-1st-edition-yipeng-liu-ed/

ebookmeta.com
Taurius Litvinavicius

Exploring Blazor
Creating Server-side and Client-side Applications in
.NET 7
2nd ed.
Taurius Litvinavicius
Kaunas, Lithuania

ISBN 978-1-4842-8767-5 e-ISBN 978-1-4842-8768-2


https://doi.org/10.1007/978-1-4842-8768-2

© Taurius Litvinavicius 2019, 2023

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

This Apress imprint is published by the registered company APress


Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
Introduction
For many years the web development community has been waiting for
something new to escape the dreaded JavaScript monopoly. Finally, the
time has arrived—first with the release of WebAssembly and now with
the release of Blazor. This book will explore Blazor in depth, and with
that, you will understand what role WebAssembly plays in this tool
stack.
To start, you will learn what Blazor is, where it runs, and how to
start using it. Blazor is convenient to code and also has tremendous
business value. Although the technology is still relatively young, I have
already managed and taken part in the development of a large-scale
platform—mashdrop.com—and from that experience, can testify as
to Blazor’s efficiency and ease of use.
This book will focus on practicality and practice; you can expect lots
of sample code and some exercises to complete. In fact, you will work
through five exercises, covering all types of Blazor, and explore some
use cases. I believe in experiential learning, which is why, from the early
stages of the book, we will be exploring Blazor by looking at code
samples and folder structures of projects. Since Blazor is not a stand-
alone technology like a programming language, the best way to learn it
is to interact with it, see what it looks like in the code, and uncover
some similarities with technologies using the same programming
language—in this case C#. You will see, you will do, and most
importantly you will learn.

Source Code
All the source code used in this book is available for download at
https://github.com/apress/exploring-blazor-2e .
Table of Contents
Chapter 1:​Introduction to Blazor
What Is Blazor?​
What Is WebAssembly?​
Blazor Types
Summary
Chapter 2:​Razor Syntax and the Basics of Blazor
Differences Between Razor and Blazor
Syntax
Comments
Sections
Blazor Binds
Binding to an Element
Events
Event Arguments
Page and Component Lifecycle Events
Summary
Chapter 3:​Blazor Components and Navigation
Pages and Navigation
Components
Parameters
Custom Events in Components
Custom Binds in Components
Layouts
Summary
Chapter 4:​Specifics of Different Types of Blazor
Default Template Overview
Blazor Server-Side Template
Blazor Client-Side (WebAssembly) Template
Injection
Static Values
Calling APIs
Adding the API Controller
Blazor Hosted
Basic Form Example for Two Types of Blazor
Multiple Select Example
Summary
Chapter 5:​General Blazor
Interact with JavaScript
Code-Behind Files
Local Storage
Pick and Save Files
Creating a Blazor Code Library
Background Tasks
Countdown Timer Example
Error Boundaries
Summary
Chapter 6:​Practice Tasks for Server-Side Blazor
Task 1
Description
Resources
Solution
Task 2
Description
Solution
Summary
Chapter 7:​Practice Tasks for Client-Side Blazor
Task 1
Description
Solution
Task 2
Description
Solution
Summary
Chapter 8:​Practice Tasks for the Blazor Hosted Version
Task 1
Description
Resources
Solution
Summary
Index
About the Author
Taurius Litvinavicius
is a businessman and technology expert based in Lithuania who has
worked with organizations in building and implementing various
projects in software development, sales, and other fields of business. He
currently works on modern financial applications and consults for
companies on technology and cost-related issues. With most of his
projects, he uses cutting-edge and cost-effective technologies, such as
Blazor.
About the Technical Reviewer
Fabio Claudio Ferracchiati
is a senior consultant and senior analyst/developer using Microsoft
technologies. He works for BluArancio ( www.bluarancio.com ). He
is a Microsoft Certified Solution Developer for .NET, a Microsoft
Certified Application Developer for .NET, a Microsoft Certified
Professional, and a prolific author and technical reviewer. Over the past
ten years, he’s written articles for Italian and international magazines
and coauthored more than ten books on a variety of computer topics.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2023
T. Litvinavicius, Exploring Blazor
https://doi.org/10.1007/978-1-4842-8768-2_1

1. Introduction to Blazor
Taurius Litvinavicius1

(1) Kaunas, Lithuania

In this book, you will learn about Blazor, a modern framework for
developing web applications using C#. You’ll learn about all the features
of Blazor, from the most basic to the more advanced. You will learn the
fundamentals of Blazor syntax and project setup, as well as exciting
modern features such as picking files and accessing them using C# in a
web browser, accessing API data using JSON, and using many of the
other latest features of Blazor. In addition, I will demonstrate what you
can achieve in Blazor and provide a few tasks for you to practice
yourself, along with the solutions I created for them.
Before you start, you need to know and prepare a few things. This is
not an introductory book to C# or .NET Core development, so you
should already have good knowledge of C# and be able to build
applications with it. It does not matter if you develop back-end
applications, Windows applications, or mobile applications; as long as
you use C#, you will find something familiar in Blazor. If you haven’t
already, you’ll need to install Visual Studio 2022 and make sure that you
have the .NET 7 SDK installed on your computer.

What Is Blazor?
Blazor is a web UI framework that allows you to use C# and .NET Core
on the front end. It allows you to develop your front-end logic in a
couple of different ways using the C# programming language, which is
something that you will explore later in this chapter.
Technical aspects aside, think of it this way: in any standard web
development project, you would need to have two people, one for the
JavaScript and the other for the back end. Sometimes you also need a
designer to work with HTML elements and CSS and do other design-
related tasks. The Blazor technology will not remove any dependency
for a designer, but it will surely remove the dependency on JavaScript.
(However, JavaScript can still be used with the Blazor technology.)
Blazor uses the Razor syntax (C# mixed with HTML), which will be
covered in Chapter 2, so any familiarity with the Razor syntax will give
you an edge when developing. There are some differences, though, as
you will see shortly. Most important, your C# code in Razor (the
.cshtml file) will execute only when the page is loaded, but in Blazor
(the .razor file) the code will execute on the loaded page on various
events, such as onclick, onchange, and others.
Blazor uses WebSocket to communicate with the server as well as
work on the server side, or it uses the WebAssembly technology, which
allows for C# to be built on the client side. This is where the different
types of Blazor technology come into play.

What Is WebAssembly?
WebAssembly is a technology that allows you to compile languages
such as C++ or C# in the browser, thus allowing Blazor to exist. It first
appeared as a minimum viable product in early 2017, and while the
technology is still in its early years, it is being co-developed by
companies such as Microsoft, Google, Apple, and others. The technology
has the support of most major browsers (
https://webassembly.org/roadmap/ )—Edge, Chrome, Firefox,
Opera, and Maxthon (MX)—and the equivalent mobile versions. With
its growth, we can expect the support to be there for a long time. In
general, Blazor simply sends a source code file to the browser, and
WebAssembly compiles it into a binary file.
WebAssembly gives you a safe, sandboxed environment, so it
appears similarly as running JavaScript. Nothing is accessible from
outside the specific browser tab the user is using.
Blazor Types
The server-side type of Blazor will run all the logic on the server side,
mainly using WebSockets to accomplish tasks (Figure 1-1). Although it
does give you an ability to use C# to write the front end, this may not be
the most efficient option. You will eliminate the need for API calls with
this option, as you will simply inject your libraries directly to the front-
end part.

Figure 1-1 Blazor Server App template in Visual Studio 2022

The client type of Blazor runs completely on the client side, on the
browser (Figure 1-2). You will have your pages on the server, but other
than that, the client side handles everything. So, this is great for
presentation websites or websites that provide calculators and other
such services. If you need database interactions or if you already have
APIs and class libraries, this will not be your choice.
Figure 1-2 Blazor WebAssembly App template in Visual Studio 2022
There are also other possible variations of these two types. One of
them is Blazor hosted; this project is client-side Blazor (Blazor
WebAssembly ) interconnected with the web API project. The client
Blazor and API program run separately, but development-wise they will
be able to share a common code library, mostly for data models. There
is also a progressive web application (PWA) option, which allows the
Blazor client to run offline. Finally, you can add API capabilities
(controllers and such) to a Blazor server project.
Along with these main projects, you will also find a Razor Class
Library project (Figure 1-3). This allows you to create Blazor
components with all the Blazor features in a code library and if needed
publish that to NuGet .
Figure 1-3 Razor Class Library template in Visual Studio 2022

Summary
There is no best type of Blazor; as you have seen throughout this
chapter, every option has its own use case. Everything depends on what
your project needs right now and, more important, what it will need in
the future. If you are not sure, simply go with the client-side version , as
it will be the most diverse option. In the next chapter, we will dive
deeper into Blazor and explore the syntax and some other topics. You
will see that while the structure may be different, for the most part,
coding happens in the same way for all types of Blazor.
Another Random Document on
Scribd Without Any Related Topics
flickered in the distance. They walked towards it. Fierce sheep dogs, with
heads like spiders, rushed at them barking.

An old shepherd came out to meet them; he drove away the dogs and
welcomed his guests with a low bow, calling Naaman by name. He had
evidently been expecting them and led them straight to the cave at the top
of the cliff overhanging Sheol.

Two young shepherds, who had been sitting by the bonfire in the cave
among a sleeping flock of goats and sheep, got up and also made a low
bow. They put more wood on the fire, spread some sheep-skins on the
ground, and wishing their guests good-night, went out together with the old
shepherd.

Issachar and Naaman sat down by the fire.

"Man is born to suffering as a spark flies upward," Issachar recalled


Ahiram's words as he gazed at the sparks in the smoking fire and he thought
"To-morrow Eliav will learn everything and will forgive and love me."

He lay down and as soon as he closed his eyes began to descend by the
dark subterranean passages into the Nut-Amon sanctuary of the god Ram;
he went on and on, but he could not reach it—he had lost his way. A small
red light flickered in the distance. He walked towards it. The light grew
bigger and bigger and became at last a red sun upon the black sky. Someone
was standing under it, dressed in white, with a face as gentle as that of the
god whose name is Quiet Heart. A quiet voice said, "Thou, Father, art in my
heart and no one knows thee but me, thy son." "Cursed be the deceiver who
said 'I am the Son'," Issachar cried, and drawing the knife from his belt was
about to strike him. But he saw the red blood flowing on the white robe.
"They shall look upon him whom they pierced and shall mourn for Him as
for a son," he recalled the prophecy, and, throwing down the knife, flung
himself at the feet of the Pierced One, crying "Who are you?"

"Ahiram, your uncle, who did you think I was? Come, wake up, my
son," he heard Ahiram's voice and woke up.
"What is the matter with you, my boy? Have you had a bad dream?" the
old man said, stroking Issachar's hair affectionately. "See, here is your
pass!"

He took a day tablet from his bosom and gave it to Issachar: the king's
seal—the sun disc of Aton—was at the top, next to the date of the month
and below was the signature Tutankhaton.'

Issachar took the tablet and gazed at it, still trembling, so that his teeth
chattered.

"Give me the stone!" Ahiram said, looking at him suspiciously,


wondering if he would refuse payment.

Issachar took the stone out of his purse and gave it to Ahiram.

"But why are you so frightened? Have you changed your mind? Won't
you go?" the old man said.

"Yes, I will go," Issachar answered.

VI

oor queen! To give the god hot fomentations when he has


stomach-ache and still believe that he is a god is no
joke," the old courtier Ay said, laughing.

Tuta, who was very fond of witty remarks, repeated it


to Dio in a moment of confidence, and she often recalled
it as she looked at Queen Nefertiti.

Mother of six children at the age of twenty-eight, she still looked like a
girl: slender girlish waist, bosom only slightly marked, narrow shoulders,
collar bones that stood out under the skin, a thin long neck—'like a
giraffe's,' she used herself to say jokingly. The round face looked childishly
tender under the high bucket-shaped royal tiara, worn low over the forehead
so that no hair showed. There was something childishly piteous in the short
slightly protruding upper lip; there was an inward brooding look and a
fathomless depth of sadness in the big lustreless, rather slanting black eyes
under the heavy drooping eyelids.

She seemed to be all on guard, as though listening, spell-bound, to


something within herself, motionless as an arrow on the bow string or a
chord stretched to the uttermost but not sounding as yet; if it did sound it
would break. It was as though she had received a mortal wound and were
concealing it from all.

Daughter of Tadukhipa, a princess of Mitanni, and Amenhotep the


Third, king of Egypt, Queen Nefertiti was King Akhnaton's half-sister:
kings of Egypt, children of the Sun, often married their sisters in order to
preserve the purity of the race.

The king and queen were so much alike that when, as boy and girl, they
used to wear almost the same clothes, people found it hard to distinguish
them. There was the same languid charm about them, the charm of a half-
opened flower drooping with the heat of the sun.
"Oh plant that never tasted running water,
Oh flower, plucked out by the roots."

Dio recalled the dirge for the dead god Tammuz when she looked at the bas-
relief of the king and queen in one of the palace chambers. They were
represented sitting side by side on a double throne; she had her left arm
round his waist, the fingers of the right hand were intertwined with his
fingers and their faces were so close together that one could hardly see her
through him; he was in her and she in him. As it said in the hymn to Aton:
"When Thou didst establish the earth
Thou didst reveal thy will to me
Thy son Akhnaton Uaenra,
And to thy beloved daughter
Nefertiti, delight of the Son
Who flourishes for ever and ever!"
It was then that this brother's and sister's marriage was made.

"They cannot be loved separately, they must be loved together—two in


one," Dio understood this at once.

After her dance on the day of Aton's Nativity, she received the rank of
'the chief fan-bearer on the right side of the gracious god-king' and, leaving
Tuta's house, settled in the palace where a room was assigned to her in the
women's quarters close to the queen's chambers. She soon made friends
with the queen, but a barrier which she herself could not understand
separated her from the king.

She was no longer afraid of his being 'not quite human': she had learned
from the queen that he certainly was human. There was profound meaning
in the flat joke about 'the god having stomach-ache.' And the horror that the
king's blasphemous words about being 'the son of God' had inspired in her
at the festival of the Sun had disappeared, too: all kings of Egypt called
themselves 'sons of God.'

She felt no fear, but something that was perhaps worse than fear.

It used to happen in the autumn when she was hunting on Mount Ida in
Crete that on a bright, sunny day mist suddenly crept up from the mountain
gorges, and the molten gold of the forest, the blue sky, the blue sea grew
dim and grey and the sun itself looked out of the fog like a dead fish's eye.
"What if the Joy of the Sun, Akhnaton, also looks at me with the eyes of a
dead fish?" she thought.

She danced for him every day, and he admired her. "Only a dancer—I
will never be anything more for him," she said to herself, with a grey fog of
boredom in her mind.

She stood for hours behind the king's throne, raising and lowering with
a slow, measured movement, in accordance with the ancient ritual, the big
ostrich-feather fan on a long pole. Sometimes when left alone with her he
turned suddenly and smiled at her with such appealing tenderness that her
heart stood still at the thought that he would speak and the barrier would
fall. But he said nothing or spoke about trifles: asked whether she was tired
and would like to sit down; or wondered at the quickness with which she
had learned to wave the fan—an art more difficult than it appeared; or, with
jesting courtesy, blessed the stupid old custom of keeping cool in winter and
fanning away the non-existent flies because it gave him a chance of being
with her.

One day Dio was reluctantly—she did not like talking about it—telling
the queen who questioned her how she had killed the god Bull on the
Knossos arena to avenge a human victim, her best friend, Eoia; how she had
been sentenced to be burned and was saved by Tammuzadad, the
Babylonian, who went to the stake in her place.

The king was present, too, and seemed to listen attentively. When Dio
finished there were tears in the queen's eyes, but the king, as though coming
to himself suddenly, glanced at them both with a strange quiet smile, and
muttered hurriedly and excitedly, repeating the same words, as he often did:

"You mustn't shave it off! You mustn't shave it off!"

It was so inappropriate that Dio was alarmed and wondered if he were


ill. But the queen smiled calmly and said, laying her hand on Dio's head:

"No, certainly not: it would be a pity to shave such beautiful hair!"

It was only then that Dio remembered that she had asked the queen a
day or two ago whether she ought to shave her head and wear a wig, as the
custom in Egypt was.

After saying these sudden words the king went out and the queen, as
though apologizing for him, said that he had not been very well lately.

It took Dio some time to forget that at that moment she had caught a
glimpse of the decrepit monster of Gem-ton—that the sun looked through
the fog like a dead fish's eye.
The same evening when he was left alone with her, he got up suddenly,
put his hands on her shoulders and brought his face near hers, as though he
would kiss her; but did not—he merely smiled so that her heart stood still:
she recalled the girl-like boy with a face as gentle as the face of the god
whose name is Quiet-Heart.

A man dreams sometimes a dream of paradise, as though in sleep his


soul had returned to its heavenly home; and on waking he cannot believe
that it has been a dream only, cannot get used to his earthly exile and is full
of sadness and yearning: such was the sadness in his face. The long lashes
of the drooping eyelids, as though weighed down with sleep, seemed moist
with tears, but there was a smile on the lips—a trace of paradise—heavenly
joy shining through earthly sorrow like the sun through a cloud.

"I heard everything you said this afternoon, only I did not want to speak
before her: one may not speak about this to anyone. You know this, don't
you?" he asked, looking at her with the same smile.

"I know," Dio answered.

"Darling, how good it is that you came, how I have been waiting for
you!"

He brought his face still nearer so that their lips almost touched.

"Do you love me?" he asked as simply as a child.

"I love you," she answered, as simply.

And it was a joy like a dream of paradise that he left her without a kiss.

On the following day, the eleventh after Aton's nativity, Dio was
standing with her fan behind the queen's chair in the palace-chamber of the
Flood, in which the flooding of the Nile was depicted.

The morning sun shone through the melting mist of the clouds into the
square opening of the ceiling, adorned with faience wreaths of vine, with
dark red clusters of grapes and dark blue leaves. The tiled walls were
painted with water-flowers and plants, the pillars, shaped like sheaves of
papyrus, had for capitals figures of wild geese and ducks hanging head
downwards—the spoils of river hunting; the paintings on the floor
represented a backwater on the Nile; fishes swam among the blue, wavy
lines of the river, butterflies fluttered among the lotos thickets, ducklings
flew up, and an absurd spotted calf galloped about with its tail in the air. As
it said in the morning hymn to Aton:
"The earth rejoices and is glad
All cattle graze in pastures green,
All plants are growing in the fields.
The birds are flying o'er their nests,
And lift their wings like hands in prayer,
Lambs leap and dance upon their feet.
All winged things fly gaily round,
They all live in thy life, O Lord!"

The king was playing with his six daughters: Meritatona, Makitatona,
Ankhsenbatona, Neferatona, Neferura and Setepenra. The eldest was
fifteen, the youngest five and there was a year's difference between the
others. When they stood in a row to say their prayers, their smoothly shaven
egg-shaped heads—royal marrows—formed a series of descending steps,
like the reeds on a shepherd's pipe.

The four elder girls were dressed in shifts of transparent linen—'woven


air'—and the two youngest were quite naked. Their arms and legs, thin as
sticks were almost brown; they wore heavy gold rings in their ears and
broad necklaces of crystal and chrysolite tears arranged like rays round their
necks.

The king's dwarf, Iagu, took part in the games; he came of the wild tribe
of Pygmies, Ua-Ua, who lived like monkeys in the trees of the marshy
forests in the extreme South. Two feet in height, bow-legged, fat-bellied,
black, wrinkled, old and monstrous like the god Bes, the primaeval monster,
he looked ferocious but was in truth as mild as a lamb; he was a splendid
dancer and an unwearying nurse to the princesses who loved and tormented
him; a faithful servant of the king's household, he would have gladly died
for each and all of them.

First they played 'nine-pins,' rolling ivory balls through reed hoops so as
to knock down at one blow nine wooden dolls with ugly faces—nine kings
hostile to Egypt.

Then Iagu's pupil, the trained white poodle, Dang, with a cap of fiery
red feathers on its head and ruby earrings, jumped through a hoop and
walked on its hind legs, holding a marshall's staff in its front paws and a
piece of antelope meat on its nose, not daring to swallow it until Iagu cried
"eat."

Then they went into the winter hot-house garden, where there were rare
foreign flowers and an ornamental pool with floating lotuses, and made two
dreadful monsters of clay—the Babylonian king, Burnaburiash and his son,
prince Karakardash, who wanted to marry the eight year old princess
Neferatona. The king was so smeared with clay that he had to be washed in
the pool.

Then they amused themselves with the cock—the bird, unknown in


Egypt, had just been brought from the kingdom of Mitanni; upset by its
long journey, the cock ruffled its feathers in gloomy silence, but suddenly
flapped its wings and crowed for the first time so loudly that all were
frightened and then delighted—'a regular trumpet'!—and began to imitate
him; the king did it so badly that the girls laughed at him.

Then they returned to the chamber and played blind man's buff. Iagu
caught the king, who then had his eyes bandaged. The girls jumped about
and scurried to and fro under his very nose, strummed on citherns, stamped
with their bare feet on the floor, imitating the oxen threshing and sang a
song:

"Hey! Hey! Hey!


It's fine and fresh to-day,
Fine workmen, oxen,
Work, work away!
Stamp upon the threshing floor!
You'll have something for your trouble.
We'll have the grain and you the straw!"

The king, awkwardly spreading out his arms, kept catching empty air or
embracing pillars. At last he caught Ankhi, Tuta's twelve year old wife.

"You moved the bandage," she cried. "There, the left eye is peeping out!
You mustn't cheat, abby!"

'Abby' was the diminutive from the Canaan word Abba—father.

"No, I haven't, it slid off," the king tried to justify himself.

"You have moved it, you have!" Ankhi kept on shouting. "I know you,
abby, you are a dreadful little rogue! But that's not the way to play. You
must catch again."

She bandaged his eyes tighter than before and he had to catch them
again.

The poodle, Dang, as though also playing, walked about on its hind legs
holding a sounding cithern in its front paws. The king, imagining from the
sound, that it was the little Zeta—Zetepenra—bent down rapidly and threw
his arms round Dang. The dog barked and licked him in the face. The king
cried out in alarm, sat down on the floor and pushed Dang away. But it
rushed up to him again, put its front paws on the king's shoulders and licked
him squealing with delight.

All laughed and shouted.

"Abby has kissed Dang! Doggy has made friends with the king."

The queen laughed, too.

"There, you've done enough fanning, sit down and rest," she said to Dio,
and Dio sat down at the foot of her chair.

"The kingdom is for the children," she suddenly recalled aloud the
king's words that she had heard from little Ankhi.
"The kingdom is for the children," the queen repeated. "And do you
know how it goes on?"

"How?"

"What is most divine in men? Tears of the wise? No, laughter of


children."

"So this is why the god Aton has children's hands for rays?" Dio asked.

"Yes, the whole of wisdom is in this: what is childlike is divine," the


queen answered and, gently placing her hand on Dio's head, looked straight
into her eyes.

"How is it you are so pretty to-day? Have you fallen in love by any
chance?" she said, smiling—'quite like him—' Dio thought.

"Why fallen in love?" she asked, smiling, too.

"Because when girls are in love they grow particularly pretty."

Dio shook her head, blushed and bending quickly down, caught the
queen's hand and began kissing it eagerly, as though she were kissing him
through her.

Suddenly she felt the queen's hand tremble. Raising her eyes and seeing
that the queen was looking at the door, she, too, looked in the same
direction. Merira, son of Nehtaneb, the high priest of the god Aton, was
standing in the doorway.

Dio had been struck by his face at the festival of the Sun and since then
she often looked at him wondering whether she felt repelled or attracted by
him.

He somewhat resembled Tammuzadad: there was the same stony


heaviness about their faces; but there had been something childlike and
piteous in the Babylonian's face, while Merira looked hopelessly grown up.
There was a stony heaviness in the low overhanging brows, in the eyes
immoveably intent and yet, as it were, unseeing, the wide cheekbones, the
firmly set jaw and the tightly closed lips that seemed sealed with bitterness
and were always ready to jeer, though they could never smile.

"He that increases knowledge increases sorrow," Dio recalled


Tammuzadad's words as she looked at that face. "To know all is to despise
all," it seemed to say, "not to curse, but merely to despise in secret, to spew
out of one's mouth." If a very courageous man firmly determined on suicide
had drunk poison and then calmly awaited death, his face would wear the
same expression.

Merira came of a very old family of the Heliopolis priests of the Sun.
He had once been the favourite pupil of Ptamose and an ardent devotee of
Amon; but he gave up the old faith and worshipped Aton. The king was
very fond of him. "You alone have followed my teaching, no one else has,"
he said, when he conferred on Merira the rank of high priest.

Merira came in while the king was sitting on the floor and the poodle,
Dang, with its paws on his shoulders, was licking his face and the
princesses were laughing and shouting.

"Abby has kissed Dang! Doggie has made friends with the king."

Merira probably failed to notice the queen and stopped in the doorway
looking intently at the king. The queen, bending slightly forward and
craning her neck, looked at Merira as intently as he did at the king.

"Merira, Merira!" she cried suddenly and there was fear in her eyes.
"Why do you look at the king like that, do you want to cast a spell over
him?" she laughed, but there was fear in her laughter.

He slowly turned to her and made the low ceremonial bow, bending
down from his waist and stretching out his hands, palms upwards.

"Rejoice, queen Nefertiti, the delight of the Sun's delights! I have come
to call the king to the Council. It seems I have come at the wrong moment."

"Why wrong? Go and tell the king."


Merira went up to the players. Laughter died down. The king jumped up
and looked at him with a guilty smile.

"What is it, Merira?"

"Nothing, sire. You were pleased to call the Council for to-day."

"Oh yes, the Council! I had forgotten..... Well, let us go, let us go!" he
hurried.

The bandage he had round his eyes during the game was dangling on his
neck; he tried to pull it off, but could not—it got tied into a knot. Ankhi
went up to him, undid the knot and took off the bandage, while Rita—
Meritatona—put on his head the royal tiara he had taken off for the game.

The girls' faces fell. The poodle slightly growled at Merira and the
dwarf made funny and frightful faces at him behind the king's back. It was
as though a shadow had come upon everything and the sun had grown dim
and looked like a 'fish's eye.'

As the king walked past the queen and Dio he looked at them dejectedly
and resignedly like a schoolboy going to a dull lesson.

Dio glanced at the queen.

"Yes, follow him," she said, and Dio followed the king.

He looked round at her with a grateful smile and Merira looked at them
both with his usual mute derision.

VII
he three walked into the Council Chamber. The dignitaries
had long been gathered there waiting for the king. When
he passed by them they prostrated themselves, sniffed the
ground under his feet and, raising their shaven, egg-shaped
heads stretched out their hands palms upwards, saying:

"Rejoice, Akhnaton, Joy of the Sun!"

Tuta, as usual, surpassed them all.

"My king, my god, who hast made me, grant me to enjoy the sight of
thy face forever!" he exclaimed, rolling his eyes so ecstatically that
everyone envied him.

The king sat down in his chair on a low alabaster platform between four
pillars. Dio stood behind him with the fan.

All looked at her curiously. She felt she was already regarded as the
king's mistress; she flushed and looked down.

A bodyguard of Hittite amazons stood in the depths of the many pillared


room. The dignitaries sat on their heels in a semicircle on mats on the floor;
only three sat on folding chairs: Tuta, Merira, and the commander-in-chief
and king's vizier, Ramose, a heavy fat old man of seventy, with a red puffy
face, like an old woman's, a courtly smile on his lips and small eyes lost in
fat, very kind and intelligent.

Grandson of General Amenemheb, fellow-soldier of the great Tutmose


the Third, the Conqueror, he had covered himself with glory in the different
campaigns he led against the wild tribes of Kush and the Sinai nomads. He
had been promoted to the rank of Vizier under King Amenhotep the Third,
Akhnaton's father, and the people were fond of him and called him 'a just
man.' He would have given his life for the king, but he regarded the new
faith in Aton and the betrayal of the old gods as madness and disaster. "The
best and most unfortunate of kings," he used to say about Akhnaton, "he is
ruining himself and his kingdom for nothing."
The sitting of the Council began. The king listened to the officials'
reports about the failure of crops, famine, rebellions, brigandage, robberies,
bribe-taking, secessions of provincial governors and feuds between them.

Standing slightly on one side Dio could see his face. He listened with
his head bent and his face seemed expressionless.

The chief of the guards, Mahu, reported on the last rising—the one in
Thebes.

"Very likely nothing would have happened had not the Lybian
mercenaries joined the rebels," he said in conclusion.

"And why did they join them?" the king asked.

"Because their salary was not paid in time."

"And why was it not paid?"

"At the prince Viceroy's orders."

The king looked at Tuta.

"Why did you do it?"

"I have laid the king's yoke upon my neck and here I bear it," Tuta
began, wondering what kind of answer he had better give: he understood
that someone had informed against him. "If I go up to heaven or come
down to earth my life is always in thy right hand, O King! I look here and I
look there and I see no light; I look upon thee, my king, my sun, and
behold, here is light! A brick may move from under other bricks in a wall
but I shall not move from under the feet of my king, my god...."

"Make haste and tell me why you did it," the king interrupted him
impatiently.

"There was no money to buy bread for the starving and so I borrowed it
from the Lybians' salary."
The king said nothing, but gave him such a look that Tuta lowered his
eyes.

"How many killed?" asked the king, turning to Mahu again.

"Less than a hundred," he answered.

He knew that more than two thousand had been killed, but, exchanging
glances with Ramose, understood that the truth should not be told: the king
would be unhappy and perhaps fall ill and nothing would be gained by it—
everything would remain as before.

"A hundred people!" the king whispered, bending his head still lower.
"Well, you won't have long now....."

"Not long to do what, sire?" Ramose asked.

"To kill people in my name!" the king answered and then asked, after a
pause: "Is there a letter from Ribaddi?"

"Yes, there is."

"Show it me."

"I cannot, sire, it is an unseemly letter."

"Never mind, show it."

Ramose gave him the letter. The king read it first to himself and then
aloud so calmly that it might have been written about someone else:

"Ribaddi, Viceroy of the King of Egypt in Canaan, thus speaks to the


King: for ten years I have been sending to thee for help but thou hast not
helped me. Now Azini, an Amorite, a traitor, has risen against thee and
gone over to the king of the Hittites. And they have gathered together
chariots and men to conquer Canaan. The enemy is at my gates, to-
morrow they will enter and kill me and throw my body to the dogs. Well
does the King of Egypt reward his faithful servants! May the gods do the
same unto thee as thou hast done unto me. My blood is on thy head,
traitor!"

"How dares this dead dog insult our god-king!" Tuta said, with
indignation.

The king looked at him again, and he subsided.

"Has Ribaddi perished?" the king asked.

"He has," Ramose answered. "He threw himself on his sword so as not
to fall into the enemies' hands alive."

"What will happen now, Ramose?"

"Why, this, sire: the king of the Hittites will have Canaan; the thieves
will undermine the wall and enter the house. We were for four hundred
years under the yoke of the nomads, and we may be for another four
hundred under the yoke of the Hittites. Your great-grandfather, Tutmose the
Great, made Egypt the head of all nations and we were the light of the
world and now this light is no more...."

"What are we to do then, Ramose?"

"You know yourself, king."

"Begin war?" the king asked.

Ramose made no answer; he knew that the king would perish and ruin
his kingdom rather than begin war.

The king was silent, too; he seemed lost in thought. Suddenly he raised
his head and said:

"I cannot!"

He paused again, thinking, and repeated:


"I cannot; no, I cannot! 'Peace, peace to the far and the near,' says my
heavenly father, Aton. 'Peace is better than war; let there be no war, let there
be peace!' This is all I know, all I have, Ramose. If you take this from me,
there will be nothing left: I shall be destitute, naked, dead. Better kill me
outright!"

He spoke simply and quietly; but Dio's heart throbbed again as on the
day before in the joy of the heavenly dream. She suddenly recalled the huge
pale phantom of Cheop's pyramid shimmering in the rosy sunlight mist over
the yellow sands of the desert: the perfect triangles—"I began to be as one
god, but three gods were in Me," in the words of the ancient wisdom—
divine triangles getting narrower and narrower, more and more pointed as
they rose to heaven and in the very last point the same frenzied ecstacy as in
Akhnaton's quiet word 'Peace'!

"O, how sweet is thy teaching, Uaenra," Tuta thrust himself forward
again—like the poodle Dang licking the king in the face. "You are the
second Osiris, conquering the world by peace and not by sword. If you say
to the water 'let there be peace'—there shall be peace."

"Listen, Ramose," the king began, "I am not such a scoundrel as


Ribaddi thought, and I am not such a fool as Tuta takes me to be...."

The poodle Dang got a flip on the nose: he was alarmed and upset. But
he was soon comforted by Ay—an old dignitary with intelligent, cold and
cynical eyes, who sat next to him.

"Don't bother, it isn't worth it," he whispered in Tuta's ear. "You see he
is playing the fool again, the crazy saint!"

"I am not such a fool as Tuta thinks," the king went on. "I know there
will be no peace on earth for a long time to come. There will be endless
war, and the longer it goes on the fiercer it will be: 'all will be killing each
other' as the ancient prophecy says. There has been a flood of water—there
is going to be one of blood. But even so, even so, let men know that there
has been in the world a man who said 'peace'!"

He suddenly turned to Merira.


"What do you think, Merira? Why do you smile?"

"I think, sire, that what you say is good, but it is not all. God is not only
peace...."

He spoke slowly, with an effort, as though thinking of something else.—

"But also what?" the king said to help him.

"Also war."

"What are you saying, my friend? War is not of God, but of the devil."

"Yes, of God, too. Two sides of the triangle meet at one point: day and
night, mercy and wrath, peace and war, Son and Father—all the opposites
are in God...."

"Is the Son against the Father?" the king asked and his hand that was
holding the arm of the chair trembled slightly.

Merira raised his eyes to him and smiled so strangely that Dio thought
'madman!' But he looked down again at once and his face turned to stone,
grew heavy with a stony heaviness.

"Why do you ask me?" he answered calmly. "You know it all better than
I, Uaenra: does not the Son know the Father? God is the measure of all
things. I say it not to you but to others: seek for measure in everything—in
peace as in the sword."

"Quite so! Quite so!" Ramose cried. "I am no friend of yours, Merira,
but for this saying I am ready to bow down at your feet—it couldn't be said
better!"

"Why are you so pleased with it?" the king asked, looking at Ramose in
surprise. "What he says is very dreadful."

"Yes, dreadful, but necessary," Ramose answered. "Ankh-em-Maat,


You-Who-live-in-Truth, you want to lift truth up to heaven and spread it
throughout the earth; but men are weak, stupid and wicked. Be merciful to
them, O King, don't ask too much of them. If you fix a ladder for them they
will climb up, but if you say 'fly,' they will fly headlong into the pit. There
is no getting on with mercy only: our mercy merely smooths the way for
evildoers. We talk much and we do little, but believe an old man like me:
nothing in the world is more wicked than empty good words, nothing more
vile than empty noble words."

"Are you speaking of me, Ramose?" the king asked, with a kind smile.

"No, not of you, Uaenra, but of those who demand a miracle of you and
do not stir a finger themselves. For twenty years I have served faithfully the
king, your father, and you; I have never told lies and I am not going to now.
Things are going ill in your whole kingdom, they are going very ill, O
King! We say 'peace,' but there is war, we say 'love,' but there is hatred, we
say 'light,' but there is darkness instead."

He got up heavily, fell at the king's feet and wept: "Have pity, sire; have
mercy! Save yourself, save Egypt, take up the sword for right and justice.
And if you do not want to do it, I don't want to see you ruin yourself and
your kingdom any more. Let me retire, I am old and want a rest!"

The king bent down to him and lifting him up embraced and kissed him
on the lips.

"No my friend, I will not let you go, and you would not go yourself—
you are fond of me... Bear up a little longer, the time is getting short—I
shall soon go myself," he whispered in his ear.

"Go where? Where?" Ramose asked with prophetic terror.

"Don't speak, don't ask, you will soon know everything!" the king
answered and got up, showing that the Council was over.

VIII
eaving the Council Chamber, they went to the Beggars'
Court. Telling the courtiers to go on, the king lagged
behind so as to remain alone with Dio. Passing through a
number of rooms they came into a small hothouse garden
where incense trees brought from the far-away Punt, the
land of the gods, grew in pots of earthenware, like huge
heather plants fine as cobweb, dropping amber rosin tears in the warm
sunshine.

The king sank down on a bench and sat for some minutes in silence
without moving. He seemed to have forgotten Dio's presence, but suddenly
he looked at her and said:

"Shame! Shame! Shame! You have looked enough at my shame, go


away!"

Dio knelt down before him.

"No, sire, I will not go away from you. As the Lord lives and as my soul
lives, whither my king goes, to shame or to honour, there will his servant go
also."

"You have seen me put to shame once, now you will see it again. Let us
go," the king said, getting up.

They entered the Beggars Court.

Three times in the year—when the Nile overflowed, at seed time, and at
harvest—the palace gates were opened to all; every beggar could go in
freely, merely giving his name to Mahu, the chief of the guards. Tables with
bread, meat and beer were placed in the courtyard: everyone could eat and
drink his fill. It was there that the king received petitions and heard
complaints.

During the first years of Akhnaton's reign these feasts were more
frequent. "Let every ninth day of the month be a day for beggars," it said in
the king's decree. Governors of provinces were on that day to distribute to
the hungry corn from the king's granaries "for the cry of the needy has come

You might also like