Download Full Web API Development for the Absolute Beginner A Step by step Approach to Learning the Fundamentals of Web API Development with NET 7 1st Edition Irina Dominte PDF All Chapters
Download Full Web API Development for the Absolute Beginner A Step by step Approach to Learning the Fundamentals of Web API Development with NET 7 1st Edition Irina Dominte PDF All Chapters
com
OR CLICK BUTTON
DOWNLOAD EBOOK
https://ebookname.com/product/asp-net-web-api-2-2nd-edition-jamie-
kurtz/
ebookname.com
https://ebookname.com/product/asp-net-web-api-2-recipes-a-problem-
solution-approach-1st-edition-filip-wojcieszyn-auth/
ebookname.com
https://ebookname.com/product/practical-asp-net-web-api-1st-edition-
badrinarayanan-lakshmiraghavan-auth/
ebookname.com
https://ebookname.com/product/restless-giant-the-united-states-from-
watergate-to-bush-vs-gore-1st-edition-edition-james-t-patterson/
ebookname.com
An introduction to invariants and moduli 1st Edition
Shigeru Mukai
https://ebookname.com/product/an-introduction-to-invariants-and-
moduli-1st-edition-shigeru-mukai/
ebookname.com
https://ebookname.com/product/consciousness-theatre-literature-and-
the-arts-2013-1st-edition-daniel-meyer-dinkgrafe/
ebookname.com
https://ebookname.com/product/science-of-memory-concepts-1st-edition-
henry-l-roediger-iii/
ebookname.com
https://ebookname.com/product/maternal-child-nursing-4th-edition-
emily-slone-mckinney-msn-rn-c/
ebookname.com
https://ebookname.com/product/applied-ei-the-importance-of-attitudes-
in-developing-emotional-intelligence-1st-edition-tim-sparrow/
ebookname.com
The First Modern Jew Spinoza and the History of an Image
Daniel B. Schwartz
https://ebookname.com/product/the-first-modern-jew-spinoza-and-the-
history-of-an-image-daniel-b-schwartz/
ebookname.com
Web API
Development for
the Absolute
Beginner
A Step-by-step Approach to
Learning the Fundamentals of
Web API Development with .NET 7
—
Irina Dominte
Web API Development for the Absolute Beginner: A Step-by-step Approach
to Learning the Fundamentals of Web API Development with .NET 7
Irina Dominte
Iasi, Romania
Acknowledgments�����������������������������������������������������������������������������xix
Introduction���������������������������������������������������������������������������������������xxi
v
Table of Contents
vi
Table of Contents
Status Codes�������������������������������������������������������������������������������������������������������43
1xx – Informational����������������������������������������������������������������������������������������43
2xx – Success�����������������������������������������������������������������������������������������������43
3xx – Redirects����������������������������������������������������������������������������������������������44
4xx – Client Errors�����������������������������������������������������������������������������������������44
5xx – Server Errors����������������������������������������������������������������������������������������46
Cookies���������������������������������������������������������������������������������������������������������������47
Summary������������������������������������������������������������������������������������������������������������49
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
Chapter 8: Routing����������������������������������������������������������������������������235
What Is a Route?�����������������������������������������������������������������������������������������������235
Route Templates������������������������������������������������������������������������������������������236
Route Segments������������������������������������������������������������������������������������������237
Route Parameters����������������������������������������������������������������������������������������239
Route Tokens�����������������������������������������������������������������������������������������������240
Route Values������������������������������������������������������������������������������������������������241
Convention-based Routing��������������������������������������������������������������������������������241
Attribute Routing�����������������������������������������������������������������������������������������������242
Route Template Precedence�����������������������������������������������������������������������������246
How to Customize Routing��������������������������������������������������������������������������������247
Route Constraints����������������������������������������������������������������������������������������������248
Creating a Custom Route Constraint�����������������������������������������������������������249
Available Constraints�����������������������������������������������������������������������������������252
Creating Hierarchical Routes����������������������������������������������������������������������������253
Summary����������������������������������������������������������������������������������������������������������260
Chapter 9: Middleware���������������������������������������������������������������������261
Middleware Usage Scenarios���������������������������������������������������������������������������264
Introducing Custom Middleware�����������������������������������������������������������������������265
Create Your Own Middleware to Add Headers��������������������������������������������������267
Making an Extension Method for Our Middleware��������������������������������������������268
Understanding the Security Headers We Added�����������������������������������������������271
X-Content-Type-Options������������������������������������������������������������������������������271
X-Frame-Options�����������������������������������������������������������������������������������������271
X-Permitted-Cross-Domain-Policies�����������������������������������������������������������272
X-XSS-Protection�����������������������������������������������������������������������������������������273
Summary����������������������������������������������������������������������������������������������������������274
xi
Table of Contents
xii
Table of Contents
xiii
Table of Contents
Index�������������������������������������������������������������������������������������������������403
xiv
About the Author
Irina Dominte(Scurtu) is an independent
consultant and trainer, international
speaker, software architect, Microsoft MVP
for developer technologies, and Microsoft
certified trainer (MCT) with a wealth of
experience. Having taught classes, workshops,
and presentations for over 2,000 hours, Irina is
passionate about coding and keeping abreast
of the latest trends and best practices in
software architecture and .NET.
Twice a year, for five months each time, Irina teaches .NET and
C# to aspiring software developers or people interested in software
development or seeking to expand their knowledge. She is an active
member of the community and has founded the DotNet Iasi User Group
and the dotnetdays.ro conference, where she connects with like-minded
developers who are eager to share their expertise and insights.
Irina is also a prolific blogger, and her website, https://irina.codes,
features a wealth of articles on various coding topics. She decided to write
this book after learning firsthand how much people struggle to grasp new
concepts without proper guidance.
xv
About the Technical Reviewer
Layla Porter is an experienced software
engineer and developer advocate specializing
in .NET technologies. She’s a Microsoft MVP,
GitHub Star, and Progress Ninja, and in 2021
she founded the #WomenOfDotNet Initiative.
Layla has spoken at developer conferences
all over Europe and North America and is a
YouTube content creator and streamer. She
spends her time hiking, reading urban fantasy,
playing video games with her husband, and
doting on her two miniature pinschers, Cookie
and Lily.
xvii
Acknowledgments
The completion of this book wouldn’t have been possible without the help
and support of many people.
First, I want to thank my husband, who supported me every step and
encouraged me. Second, my daughter, Ilinca, who luckily enjoyed going
to daycare so I could write this book, and my in-laws, who were there to
babysit when I needed them.
Furthermore, I would like to express my appreciation to all those who
took the time to review my manuscript and provide constructive feedback
that helped refine the content. Special recognition goes to my tech
reviewer, Layla Porter, and my friends, Maria Rusu, Andrei Diaconu, and
Alexandra Nechita.
Last, but not least, thanks to my former students Tatiana Ciurescu and
Cosmin Dumitru, who were brave enough to shift their careers into tech
and never stopped learning.
xix
Exploring the Variety of Random
Documents with Different Content
number of vicious tugs to bring the lead to its lowest point, she would
return to her book. It was at one of these more energetic pumpings
that the intruder’s presence caught her eye. She started and her
face lengthened into an expression of humorous, half scandalized
astonishment. This distraction lasted so long that the lead crept up
unnoticed and the wind gave out bringing the melody to an abrupt
and wheezy halt.
“Minna!” The Princess’s voice only confirmed the certainty Ludovic
had felt as to the player.
“Pardon!” Minna energetically seized the handle and gave several
vigorous pulls. “My book was so exciting that I forgot.”
The melody rose again, the absorbing book lay on the floor, and for a
while the bellows received a pretty girl’s full, almost feverish,
attention.
Presently she looked again at Ludovic and made a comic expression
of disgust. He stood irresolute, telling himself that he ought to go, yet
yielding to the temptation to linger. The girl’s facial suggestion was
now supplemented, after a vehement sending down of the indicator,
by a pantomime of weariness. There must have been an object in
these signals, yet Ludovic did not take the hint. So Minna,
abandoning vagueness, plainly beckoned to him, making signs that
he should take her place at the bellows. The invitation could scarcely
be disregarded. He came forward and took his position by the lever,
while the girl slipped away and settling herself on a more
comfortable bench, avidiously resumed her exciting story.
For about half an hour the music continued, Ludovic gravely keeping
to his work at the bellows, and Minna, save for an occasional sly
upward glance, seeming absorbed in her book. There were breaks in
the playing between the ending of one piece and the beginning of
another. In one interval of silence, as Ludovic stood waiting for the
organ to swell out again, he looked up and saw the Princess
standing before him. His involuntary glance at her face told him
nothing. He bowed low.
“Pardon, Princess,” he said soberly, “the Countess was tired and I
ventured to take her place.”
Minna had sprung up and came forward with a look of mingled
apprehension and sly enjoyment of the situation.
“It is true, Highness,” she corroborated. “My arms began to ache and
my book was so exciting that I asked Herr von Bertheim to blow till I
had rested and the duel was over. One cannot blow the organ
properly when one is in a state of terrific suspense.”
The Princess’s face gave no indication of how she took the situation.
“It is perhaps more a man’s work,” she said coldly. “I am obliged to
Herr von Bertheim. I did not know he was in the chapel.”
Still no sign whether his presence gave her offence or not.
“I was passing down the Broad Walk when the music stopped me
and drew me in,” he explained. “I had no idea, until I saw the
Countess, that the player was your Highness.”
“It is perhaps an unusual thing,” she returned with a touch of
bitterness, “to find a person in my position cultivating an art. I do not
know whether it is one of the things we are bidden to leave to the
less exalted, and not meddle with. Your ignorance can scarcely be
blamed, sir.”
“I cannot blame it, Princess, unless my presence has given you
offence.”
“That ought never to be,” she returned quickly, “seeing how welcome
it once has been.”
“I could never presume on that chance service,” he said simply.
“No.” She spoke abstractedly, mechanically. Minna had fidgetted
away behind the screen to the door, perhaps on the watch. “That
makes it all the more acceptable,” the Princess added in the same
distant tone, a tone which impelled him to reply.
“I take the hint, Highness.”
He half turned away, when the murmur of her voice recalled him.
“You need not take more than is meant to be given,” she said, and
there was a sweetness in her tone he had never heard before. She
gave a quick glance to where Minna stood, and then added, “If I
seem far less grateful than an”—she gave a little shrug—“an
ordinary woman would be you must not impute the churlishness to
me but to my position. It is one of the attributes of royalty to be
above the common feelings of the outside world.” The words
seemed forced from her, the vent of a grievance, long resented, ever
dwelt on. The situation was but an opportunity not the cause of its
expression.
“I never could dream of imputing anything but graciousness to your
Highness,” Ludovic protested eagerly. “I have no right here, I know:
but being free of the Court I ventured to cross the park on my way
home. Then the music caught my ear and I came in, thinking to listen
without being seen.”
She was looking away, now her glance fell on him. “You come to
Court?” she asked in a tone that was scarcely indifferent and yet
tantalisingly vague.
“I had the honour to be present at the Hof-Ball last week.”
“Ah, I wondered——”
He understood that she was thinking of his recognition of her at the
fortune-teller’s. His next words seemed surprisingly bold.
“Your Highness often plays here? Is it too much to ask to be allowed
to officiate as organ-blower again?”
A little hardening of the Princess’s face told him that his temerity was
resented. She gave him no answer. “Minna!” she called, “Come,
dear; it is late.”
But before Minna could reach them he had spoken again.
“Pardon, Highness,” he said with great restraint yet urgently. “You
have not forbidden me.”
But she spoke no word to him again. “Come, dear,” she said, linking
her arm in Minna’s, and so they went across the chancel to the royal
entrance leading by a covered way to the palace. He stood looking
after them hoping for what he knew was beyond hope. Minna
opened the door and the Princess passed out of sight without a
backward look. Minna glanced round with an inscrutable laugh.
CHAPTER V
RUPERTA AND LUDOVIC
THE birds in the woodland surrounding the royal chapel sang lustily,
as though exulting in the fact that the tones of their great opponent,
the organ, were for once so soft and weak as to yield them an easy
victory in the game of out-singing one another. The lowness of tone
in the dragging melody seemed to be the interpretation of a heavy
heart; it spoke the language of sadness and of parting.
Ludovic had taken his place early beside the organ, but had waited
long for the player; long, indeed, past her usual hour. Waited till he
was forced to ask himself whether the last night had not been the
end of that informal, delicious acquaintance. Was he never to see
the Princess again, at least as he had known her? Never again
watch fascinated for those sweet glimpses of the sun breaking
through the cold mist? There was so much he had to tell her, that he
felt he dared say now, if only the chance were not gone. He waited,
hoping and despairing, till the afternoon seemed turning to evening;
he watched the door through which she would come till he hated it
for mocking him with its immovability. At last, when he was sure that
the parting was over, unrealized, he looked up to see the door open
and the Princess and Countess Minna coming towards him.
Eagerly he went forward; ah! she was so cold. There was no trace of
the feeling she had given glimpses of the night before. The hand that
touched his lips was as chill as a statue’s. She had repented, yet
why, then, had she come? There was, at least, no sign of
disapproval in that stately greeting. She went straight to the
keyboard, he to his post, Countess Minna, unusually serious, to her
accustomed corner. So the music began to float gently through the
place; it was, or at least seemed, less interesting to him than usual;
he had so much to say, and the soft introit interposed between him
and his desire. Still, he could but wait; it was not for him to pluck
open the blossom of his hopes before his glorious sun should ripen
them. He was content to be near her, thankful that she had come,
overjoyed yet sad to think what her presence meant. When the
playing was over what would her words be? Not so frigid as her
greeting surely; yet the very coldness gave to her slightest
unbending a value far surpassing the warmth of an impulsive nature.
The sinking sun struck horizontally through the richly tinted windows,
and the shadows of the trees, just stirred by the almost windless
atmosphere, danced slowly and languidly on the wall, the pillars and
richly carved stalls, as though keeping time and character with the
music. The sands of his last day were running low, the dreamy
music, though he loved it, made him impatient. Then an idea came
to him. Why should he not ask Countess Minna to release him and
take his place, so that he might go round and be at least within sight
of the Princess? He hesitated. Would she not be offended if he broke
the tacit understanding between them? Certainly her reception of
him had given no encouragement to impatience or forwardness. It
was his duty to respect her slightest hint, to let the initiative always
come from her, above all, never to make her task (if he dared believe
it were one) more difficult. Yet every argument failed against his
intense desire. He looked round at the demure reader coiled up
snugly in her corner; she glanced up as his movement caught her
eye, and laughed as he signed to her. Then she shook her head; she
was sharp enough, and guessed what he wanted, but—perhaps she,
too, thought it madness. Anyhow it was with a deprecating
expression that she rose and came to him.
“Will you not relieve me for five minutes?” he asked.
She kept her hands behind her. “Why?” she asked. “You are surely
not tired.”
“No; not tired, but——”
“The Princess hates any one to look over her.”
“May I not see her from a distance?”
“You are a fool, with apologies for the liberty of telling you so, Herr
Lieutenant.”
“I dare say I am. But why?”
“To long for fruit that is out of your reach.”
“Perhaps. Still I shall not say it is sour.”
“Heaven forbid! No, you will not do that. Look! Quick! The wind is
out. Pump for your life! So! Shall I tell you further why you are a
fool?”
“If you please.”
“Because you do not seem to have the sense to know what would
happen if your organ-blowing were to come under the notice of our
Chancellor.”
“I can guess.”
“The grapes would be sour, at least they would set your teeth on
edge, though your sense of taste would soon be over.”
“I dare say.”
“And yet it is worth the risk, eh? It is well that you are brave. This is
the last time we meet here.”
“As the Princess wills.”
“She has willed it. I told her she was a—not wise to come to-day. You
don’t think of me and the risk I run. I am not anxious to meet you in
the next world yet. There! as you are brave, and this is truly the last
time, give me the handle. But you will worry the Princess.”
With a word of thanks he had turned towards the front of the organ,
when her voice called him back sharply. “Take care! We are
watched. Bend down quickly.”
She sprang forward and pushed him away, taking his place at the
handle. “Keep under the curtain,” she directed, pumping away
vigorously. “Out of sight. A man is looking through the window. I just
saw his head from where I stood. It was Udo Rollmar. If he sees you
—ah, he must not see you. Hist! there he is again.”
Peeping through a slight parting in the curtains that screened the
organ-blower’s seat, Ludovic could see a foxy face looking in
through one of the leaded panes. He remembered what Countess
Minna had told him of the Chancellor’s son, that he was in love with
the Princess.
“I am not afraid of that fellow,” he said. “Why should I hide from
him?”
Minna threw up her hand in distress. “Oh, you idiot! You will ruin us
all. Can you not think of the Princess? Now will you hide? Quickly!
He is surely coming in. Oh, we are ruined! We are lost!”
The face had disappeared from the window. The situation was
critical. At any moment Captain Rollmar might show himself over the
screen. Minna was beside herself with terror, while the music still
floated out under the fingers of the unconscious player.
“Oh, this is awful!” she gasped in despair, looking helplessly round
the trap in which they seemed caught. “Ah!” She pointed to the
narrow door which gave admittance to the interior of the organ. “In
there, for Heaven’s sake!” she besought him. But he hesitated and
hung back.
“It is unnecessary,” he objected quietly.
Even in her distress she could not help marvelling at his coolness.
“You are mad, or, at least, horribly selfish,” she exclaimed
indignantly. “If you are tired of your life because you cannot have
what you want, I promise you I am not. Man, to save the Princess’s
honour and my life, will you not go in there till the danger is past?”
She spoke with rapid vehemence, trembling with fear and
excitement.
“I will obey you,” he said with a half laugh, and entered the narrow
opening. She shut and fastened the door, and then sprang back to
the bellows handle. Just in time; for she had scarcely given one
vigorous pull when the curtain parted, and the expected face
appeared. She affected to give a start and a little scream.
“Ah, Captain, how you frightened me. I thought it was the devil, who
they say once came after a priest in this very chapel.”
His suspicious eyes were searching the place as he replied with a
cunning smile, “It is neither the devil nor a priest this time, little
Minna, although if the old gentleman has taste he would be more
attracted by the organ-blower than by the clergy.”
She made him a mocking curtsey, and, by design or accident, let the
wind run off, bringing the music to a stop.
“Highness!” she cried, “here is Captain von Rollmar.”
If it was in apprehension that the Princess joined them she did not
show it.
“May I blow for you, Princess?” Captain Udo asked with a bow.
“Thank you, I have finished playing,” she returned coldly. “The light is
fading. Come, Minna.”
The vulpine eyes were feasting on her, so contemptuously majestic
in comparison with his cunning insignificance. “Do not hurry away,”
he suggested with all a vain, clever man’s self-confidence. “It is
pleasant here.”
“Yes; but we have stayed long enough. It grows chilly. Let us go,
Minna.”
Minna had placed herself a little behind the Captain, so that, unseen
by him, she could give her mistress a warning glance.
“We might stroll out into the park,” she suggested, “if your Highness
is agreeable. It is a delicious evening, and Captain von Rollmar
would be our escort.”
The proposal suited the Captain exactly, and as for the Princess she
comprehended the intention behind it and agreed. So the three went
out together, leaving Ludovic a prisoner in the organ.
They walked up and down the great avenue till it was time to go in,
Captain Udo in such a state of content that the amiability working out
in his expression almost eclipsed its foxiness. He was too happy to
think of suspicion. It was dusk when they turned up a path leading to
one of the private entrances of the palace. But there was hardly any
scandal to fear in the company of the Chancellor’s son; at least the
wily old terror would have to keep his blame at home.
“Oh, Highness,” Minna cried suddenly, “I have left my book back in
the chapel. How stupid I am! May I run back for it? You shall not wait
for me a minute.”
“Does the book matter?” the Princess asked.
“Oh, Highness,” she replied with a humorous look of entreaty, “it is
so interesting, and I have promised myself such a delicious hour with
it to-night. May I run?”
“You are a spoilt child, Minnchen,” her mistress laughed.
Captain Udo made a half-hearted offer to fetch the book, but Minna
decided that he might not find it at once; she knew exactly where it
was. He should stay with the Princess for the one short minute the
errand would take. Accordingly he, nothing loath, remained and
Minna sped off to the chapel. Only to find the door locked.
The book must indeed be interesting to make her look so troubled at
its loss, Captain Udo thought as she rejoined them empty-handed.
But she would send a servant for it, she said.
“You might have thought of that before, and saved yourself the
trouble, silly child,” the Princess remarked.