Professional Documents
Culture Documents
(Download PDF) Ultimate Asp Net Core Web Api 2Nd Edition Marinko Spasojevic Online Ebook All Chapter PDF
(Download PDF) Ultimate Asp Net Core Web Api 2Nd Edition Marinko Spasojevic Online Ebook All Chapter PDF
(Download PDF) Ultimate Asp Net Core Web Api 2Nd Edition Marinko Spasojevic Online Ebook All Chapter PDF
https://textbookfull.com/product/pro-asp-net-core-mvc-develop-
cloud-ready-web-applications-using-microsoft-s-latest-framework-
asp-net-core-mvc-sixth-edition-adam-freeman/
https://textbookfull.com/product/beginning-database-programming-
using-asp-net-core-3-with-mvc-razor-pages-web-api-jquery-angular-
sql-server-and-nosql-1st-edition-bipin-joshi/
https://textbookfull.com/product/creating-asp-net-core-web-
applications-proven-approaches-to-application-design-and-
development-1st-edition-dirk-strauss/
https://textbookfull.com/product/pro-asp-net-core-identity-under-
the-hood-with-authentication-and-authorization-in-asp-net-
core-5-and-6-applications-1st-edition-adam-freeman/
Mobile Development with NET Build cross platform mobile
applications with Xamarin Forms 5 and ASP NET Core 5
2nd Edition Can Bilgin
https://textbookfull.com/product/mobile-development-with-net-
build-cross-platform-mobile-applications-with-xamarin-
forms-5-and-asp-net-core-5-2nd-edition-can-bilgin/
https://textbookfull.com/product/programming-microsoft-asp-net-
mvc-dino-esposito/
https://textbookfull.com/product/asp-net-jquery-cookbook-second-
edition-allana-sonal-aneel/
1
2
TABLE OF CONTENTS .....................................................................3
3
3.4 Repository Pattern Logic ........................................................................ 38
4
7.3 Testing Content Negotiation ................................................................... 74
5
13 VALIDATION ..................................................................... 114
6
16.2 Paging Implementation ........................................................................ 151
17.3 How to Implement Filtering in ASP.NET Core Web API ........................ 162
19.2 How to Implement Sorting in ASP.NET Core Web API .......................... 174
7
20.2 How to Implement Data Shaping ......................................................... 183
8
24.1 Required Package Installation and Configuration................................. 216
9
27.4 Big Picture ........................................................................................... 251
10
Configuration in .NET Core is very different from what we’re used to in
.NET Framework projects. We don’t use the web.config file anymore, but
instead, use a built-in Configuration framework that comes out-of-the-box
in .NET Core.
Let's open Visual Studio and create a new ASP.NET Core Web Application:
11
Now let’s choose a name and location for our project:
Next, we want to choose a .NET Core and ASP.NET Core 5.0 from the
dropdown lists respectively. Also, we don’t want to enable OpenAPI
support right now. We’ll do that later in the book on our own. Now we can
proceed by clicking the Create button and the project will start initializing:
12
1.2
After the project has been created, we are going to modify the
launchSettings.json file, which can be found in the Properties section of
the Solution Explorer window.
13
This is convenient since we are developing a Web API project and we
don’t need a browser to check our API out. We will use Postman
(described later) for this purpose.
You’ll also notice the sslPort property which indicates that our
application, when running in IISExpress, will be configured for HTTPS
(port 44370), too.
Additional info: Take note that this HTTPS configuration is only valid in
the local environment. You will have to configure a valid certificate and
HTTPS redirection once you deploy the application.
There is one more useful property for developing applications locally and
that’s the launchUrl property. This property determines which URL will
the application navigate to initially. For launchUrl property to work, we
need to set the launchBrowser property to true. So, for example, if we
set the launchUrl property to weatherforecast , we will be redirected
to https://localhost:5001/weatherforecast when we launch our
application.
Program.cs is the entry point to our application and it looks like this:
14
{
webBuilder.UseStartup<Startup>();
});
}
If you are familiar with how things work in .NET Core 1.0, you will find
this code considerably smaller than it used to be.
You might wonder why some parts are missing like the UseKestrel() or
the UseIISIntegration() . The CreateDefaultBuilder(args)
method encapsulates all that stuff and makes this code more readable,
but it keeps all the magic present. You can still fine grain the
configuration if you want to.
When we open the Startup class, we can find the constructor and the two
methods which we’ll extend quite a few times during our application
development.
15
Since larger applications could potentially contain a lot of different
services, we can end up with a lot of clutter and unreadable code in the
ConfigureServices method. To make it more readable for the next
person and ourselves, we can structure the code into logical blocks and
separate those blocks into extension methods.
So, let’s start writing some code to see how it all adds up.
We are going to create a new folder Extensions in the project and create
a new class inside that folder named ServiceExtensions. The
ServiceExtensions class should be static.
16
If we want to send requests from a different domain to our application,
configuring CORS is mandatory. So, to start off, we’ll add a code that
allows all requests from all origins to be sent to our API:
We are using basic CORS policy settings because allowing any origin,
method, and header is okay for now. But we should be more
restrictive with those settings in the production environment. More
precisely, as restrictive as possible.
17
What is Dependency Injection (DI) exactly and what is IoC (Inversion of
Control)?
In a system that is designed around DI, you may find many classes
requesting their dependencies via their constructors. In this case, it is
helpful to have a class that manages and provides dependencies to
classes through the constructor.
In the Solution Explorer, we are going to open the Controllers folder and
locate the WeatherForecastController class. Let’s modify it:
[Route("[controller]")]
[ApiController]
public class WeatherForecastController : ControllerBase
{
private ILoggerManager _logger;
29
Another random document with
no related content on Scribd:
Plate 7.
22
GOOSE.
23
WILD DUCK.
24
TURKEY.
H. Adlard, sc.
Plate 8.
26
ENTRÉE OF CUTLETS.
25
HARE.
27
FRICANDEAU OF VEAL.
H. Adlard, sc.
MODERN COOKERY.
CHAPTER I.
Soups.
Ingredients which may all be used for making Soup of various kinds:—
Beef—Mutton—Veal—Hams—Salted Pork—Fat Bacon—Pigs’ Ears and Feet—
Venison—Black and Moor Game—Partridges—Pheasants—Wild Pigeons—
Hares—Rabbits—Turkeys—Fowls—Tame Pigeons—Sturgeon—Conger Eel,
with all sorts of Fish usually eaten—All Shell-Fish—Every kind of Vegetable and
Herb fit for food—Butter—Milk—Eggs—Rice—Sago—Arrow-Root—Indian Corn
—Hominy—Soujee—Tapioca—Pearl Barley—Oatmeal—Polenta[9]—Macaroni
—Vermicelli—Semoulina, and other Italian Pastes.
9. The name given in English commerce to the maize flour or meal of Italy.
12. We are unable to give further space to this subject here, but may probably
resume it at another part of the book, if practical.
Cut some slices a quarter of an inch thick from a stale loaf; pare
off the crust and divide the bread into dice, or cut it with a small
paste-cutter into any other form. For half a pound of bread put two
ounces of the best butter into a frying-pan, and when it is quite
melted, add the bread; keep it turned over a gentle fire until it is
equally coloured to a very pale brown, then drain it from the butter,
and dry it on a soft cloth, or on a sheet of paper placed before a
clear fire upon a dish, or upon a sieve reversed.
SIPPETS À LA REINE.