ASP.NET Core Web API .NET 6 2022 - 1. Create Project & Quick Tips

Teddy Smith
3 Jan 202212:10

Summary

TLDRIn this tutorial, Teddy introduces viewers to building a Pokémon review system using ASP.NET Web API version 6, emphasizing its importance for C# developers. Aimed at beginners, the video guides through setting up the project in Visual Studio, utilizing the built-in Swagger for API testing instead of Postman. Teddy explains the significance of APIs as a means for programs to communicate securely and intuitively, highlighting the high demand for ASP.NET Web API skills in the job market.

Takeaways

  • 🌟 The video is a tutorial on building a Pokémon review system using ASP.NET Web API version 6.
  • 👋 Teddy, the presenter, welcomes viewers to his YouTube channel and introduces the topic.
  • 📚 The tutorial is beginner-friendly, requiring basic knowledge of C# and object-oriented programming.
  • 📈 Web API is highlighted as an important framework for C#/.NET developers, with widespread industry demand.
  • 🔍 A UML diagram is provided for reference, serving as a blueprint for the app's structure and functionality.
  • 🛠 ASP.NET 6 comes with built-in Swagger, which simplifies API testing and eliminates the need for Postman.
  • 💡 Swagger provides a visual interface for API endpoints, making it easier to interact with the API without setting up each request manually.
  • 🚀 The tutorial guides viewers through creating a new project in Visual Studio, emphasizing the importance of selecting the correct Web API template.
  • 🔑 Open API support is enabled by default to utilize Swagger, and authentication is set to 'None' initially for simplicity.
  • 🛑 The 'Program.cs' file is identified as crucial for wiring in functionality and middleware, which processes HTTP requests sequentially.
  • 🔄 APIs are likened to 'SQL over HTTP', allowing secure and intuitive access to data through endpoints, facilitating communication between programs.

Q & A

  • What is the main topic of the video?

    -The video is about building a Pokémon review system using ASP.NET Web API version 6.

  • Why is Web API considered important for C# .NET developers?

    -Web API is important because it has become a dominant framework and is often required knowledge in interviews for .NET developer positions.

  • What level of C# knowledge is expected for this tutorial?

    -The tutorial is beginner-friendly and expects the viewer to have a basic understanding of C#, including knowledge of classes and object-oriented programming.

  • What is the purpose of the provided UML diagram?

    -The UML diagram serves as a blueprint for the app, providing an outline to follow during the development process.

  • What does the built-in Swagger feature in ASP.NET Web API do?

    -Swagger provides a visually pleasing interface for testing the API without the need for Postman, allowing users to execute and test API endpoints easily.

  • What is the significance of enabling Open API support in the project creation?

    -Enabling Open API support integrates Swagger into the project, which is necessary for using the built-in API testing features.

  • Why is the WeatherForecast example controller unnecessary for this project?

    -The WeatherForecast controller is a dummy example provided by Microsoft to demonstrate API capabilities and is not needed for the Pokémon review app.

  • What role does the Program.cs file play in the project?

    -Program.cs is the main settings file where functionality such as database support or identity framework can be wired in.

  • What is the analogy used in the script to explain middleware in web development?

    -Middleware is compared to a car wash, where an HTTP request goes through a series of processes or 'cleansing steps' before reaching its destination.

  • How are APIs described in the video, and what purpose do they serve?

    -APIs are described as 'SQL over HTTP,' serving as a way for programs to communicate with each other in an intuitive, secure manner, allowing access to data through endpoints.

  • What advice is given for learning about APIs and securing a job?

    -The advice is to keep learning and practicing with APIs, as there is a high demand for ASP.NET Web API knowledge in the job market.

Outlines

00:00

🚀 Introduction to Building a Pokémon Review System with ASP.NET Web API

In this introductory paragraph, Teddy welcomes viewers to his YouTube channel and announces the creation of a Pokémon review system using ASP.NET Web API version 6. He emphasizes the importance of Web API for C# developers and assures that the tutorial is beginner-friendly. Teddy expects viewers to have a basic understanding of C# and object-oriented programming but promises that even with minimal knowledge, one can follow along. He encourages viewers to download a UML diagram that will serve as a blueprint for the app development process. Teddy also mentions the built-in Swagger feature in ASP.NET Web API, which provides a visual interface for testing the API without the need for Postman. He gives a brief overview of how the app will look and assures that the tutorial will be both instructive and user-friendly.

05:02

🛠️ Setting Up the ASP.NET Web API Project and Understanding Key Components

This paragraph delves into the setup process for the new project in Visual Studio. Teddy guides viewers on how to create a new Web API project, ensuring they select the correct template for .NET 6 and enabling Open API support for Swagger integration. He explains the importance of the 'Program.cs' file, which acts as the main entry point for wiring in functionality and middleware. Middleware is likened to a 'technological car wash' that processes HTTP requests sequentially. Teddy also clarifies that while APIs may not have a flashy UI, they are crucial for secure and intuitive data access. He simplifies the concept of APIs as 'SQL over HTTP,' explaining how they allow for data retrieval through endpoints tied to database tables. The paragraph concludes with advice on focusing on learning and understanding the core components of the project without getting bogged down by less essential elements.

10:03

🌐 Understanding APIs and Their Role in Modern Web Development

In the final paragraph, Teddy discusses the significance of APIs in web development. He describes APIs as a means for programs to communicate with each other, allowing for secure and efficient data exchange. He uses the analogy of Google's vast data, explaining how APIs enable access to specific data through URLs, which are tied to objects or database tables. Teddy clarifies that APIs return data in JSON format, which, while not visually appealing, is practical for quick use in applications like React or for data processing. He encourages viewers to persevere in learning about APIs, despite the initial challenge, as they are in high demand in the job market. The paragraph ends with a call to action for viewers to like, subscribe, and follow along for more educational content.

Mindmap

Keywords

💡ASP.NET Web API

ASP.NET Web API is a framework for building HTTP services, which is pivotal for C# .NET developers. In the video, it is highlighted as an essential tool for developers, especially in interviews, signifying its importance in the industry. The script mentions building a 'Pokemon review system' using ASP.NET Web API version 6, indicating its use for creating web services.

💡Web API

Web API refers to the protocols and tools used by programs to communicate with each other over the web. The video emphasizes that Web API has become a dominant framework in the industry, suggesting that knowledge of it is crucial for developers. It is used to create RESTful services, as illustrated by the video's project of building a review system.

💡Swagger

Swagger is an open-source software framework used to design, build, document, and use RESTful Web services. In the context of the video, it is mentioned as being built into ASP.NET 6, which simplifies API testing and documentation without the need for additional tools like Postman. The script describes Swagger as providing a 'visually pleasing way' to interact with the API.

💡.NET 6

.NET 6 is the latest version of the .NET platform at the time of the video's recording. It is highlighted as the recommended version for beginners to learn and work with, as it includes built-in features like Swagger and is expected to be in high demand in the job market. The script suggests that starting with .NET 6 will prepare developers for future job opportunities.

💡UML Diagram

A UML (Unified Modeling Language) diagram is a visual representation used to design and document software systems. In the video, the UML diagram is suggested as a blueprint for the app being developed, providing an outline that the developers will follow throughout the project. It is used to visualize the structure and functionality of the Pokemon review system.

💡Object-Oriented Programming

Object-Oriented Programming (OOP) is a programming paradigm that uses objects and classes to design applications. The video mentions that a basic understanding of OOP is necessary to follow along with the tutorial, indicating that the construction of the Pokemon review system will involve creating classes and objects to manage data and functionality.

💡Program.cs

Program.cs is the main entry point for a .NET application, where the execution of the program begins. In the video, it is described as a crucial file for wiring in functionality and services, such as database support or identity frameworks. It is where the setup for the Pokemon review system's services and middleware is configured.

💡Middleware

Middleware in web development is software that handles HTTP requests and responses between the client and the server. The video uses the analogy of a 'technological car wash' to explain how middleware processes requests sequentially, performing tasks like authorization and HTTPS redirection before the request reaches the intended endpoint.

💡API Endpoints

API endpoints are the individual URLs in an API that perform specific operations. The video script mentions endpoints in the context of Swagger, where they are used to test and interact with the Pokemon review system's functionality. Endpoints allow for the retrieval and manipulation of data through the API.

💡JSON

JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write and for machines to parse and generate. In the video, JSON is presented as the format in which the API returns data, which can then be used in applications like React or other databases.

💡Authentication

Authentication is the process of verifying the identity of a user or device. The video mentions that authentication will be added later to the project, indicating that the initial setup of the Pokemon review system does not include security measures but will eventually require them to ensure that only authorized users can access certain API endpoints.

Highlights

Introduction to building a Pokémon review system using ASP.NET Web API version 6.

Web API's importance for C# .NET developers and its prevalence in the industry.

Beginner-friendly approach, not requiring extensive C# knowledge, just basic OOP concepts.

Use of a UML diagram as a blueprint for the app development process.

Integration of Swagger for API testing without the need for Postman.

Explanation of how Swagger provides a visually pleasing way to interact with the API.

Instructions on setting up a new ASP.NET Web API project in Visual Studio.

Emphasis on choosing the correct project template for .NET 6 and Web API.

Enabling Open API support to integrate Swagger for API documentation and testing.

The role of Program.cs as the main settings file for wiring in functionality.

Explanation of middleware as a sequential process for HTTP requests.

The significance of APIs as a means for programs to communicate and share data.

APIs described as 'SQL over HTTP' for intuitive data access.

The practical demonstration of API endpoints returning JSON data.

Discussion on the demand and job opportunities for ASP.NET Web API developers.

Encouragement for beginners to stick with learning APIs for career prospects.

Call to action for viewers to like, subscribe, and support the channel.

Transcripts

play00:00

what's up guys this is teddy welcome to

play00:02

my youtube channel this video we're

play00:04

going to be building a pokemon review

play00:07

system in asp.net web api

play00:11

version 6

play00:13

2022 the newest the latest the greatest

play00:16

uh and web api is going to be a very

play00:19

important framework for csharp.net

play00:21

developers um

play00:23

web apis and web api in particular has

play00:27

literally taken over the scene any place

play00:29

that you interview is going to require

play00:31

that you know web api and this is going

play00:33

to be like a

play00:35

beginner friendly like i don't expect

play00:37

you to know a lot about c sharp i expect

play00:39

you to have like a beginner's knowledge

play00:42

you probably need to know like a class a

play00:43

little bit of object oriented

play00:45

programming in order to know what's

play00:46

going on but you could even if you just

play00:48

had a very beginner's level knowledge of

play00:51

this you could still make it work i

play00:54

think and you could still follow along

play00:55

so go ahead download this uml diagram

play00:59

because we're going to be referring to

play01:00

this lot and this is going to give us

play01:02

like an outline like a blueprint of our

play01:04

app we're going to be following along as

play01:06

we kind of go through this and just to

play01:09

kind of show you beforehand like what

play01:11

our app like is actually going to look

play01:13

like apis don't really have like a big

play01:16

ui like they don't they're not as

play01:19

uh visually stunning as a front-end app

play01:22

but the great thing about asp.net web

play01:24

api and uh.net 6 is now they have

play01:27

swagger built into it so you don't need

play01:29

postman and swagger is already built

play01:32

into your api and it's going to give you

play01:35

like a very visually pleasing way to

play01:38

look at

play01:39

our uh um like just imagine our uml

play01:42

diagram

play01:43

is what's going to be viewed in swagger

play01:46

and this is going to give you like a

play01:48

really quick way like watch this you can

play01:50

just go in here you can execute it and

play01:53

it will quickly give you the ability to

play01:56

test your api so we've got electric leaf

play01:59

water right here and

play02:01

yeah like i said it's going to be it's

play02:03

going to save you a ton of time so don't

play02:06

worry about postman because swagger is

play02:08

gonna have everything that we need and

play02:10

yeah it's pretty much okay so enough

play02:13

chit chat let's go ahead let's go into

play02:15

visual studio and we're going to

play02:18

actually create our new project so go

play02:20

down here create a new project on the

play02:23

right

play02:25

and type into our templates we're going

play02:27

to type in web api

play02:32

web api

play02:34

i'm going to bring down my mic here so i

play02:37

can see a little bit better then go to

play02:39

this very first one make sure that you

play02:41

get the linux mac windows c-sharp one

play02:44

because that is indicative of core and

play02:47

make sure like i said make sure it's

play02:48

core make sure it's web api so that you

play02:50

get the the right one and you're not

play02:52

following it wrong along with the wrong

play02:54

template because that's what it's going

play02:55

to do it's going to generate a template

play02:57

for you

play02:58

so we're going to go here

play03:00

and we're going to type in pokemon

play03:02

review

play03:05

app pokemon review app

play03:08

very simple

play03:09

uh

play03:10

self-explanatory name it if you want to

play03:12

name it something different or if you

play03:14

maybe if you even want to create like

play03:16

your own you don't want to even be about

play03:18

pokemon make it a dog review app make it

play03:21

a review app it uh just and just follow

play03:23

along you could definitely do that but

play03:25

if you're a beginner i would just

play03:27

recommend following along with just uh

play03:30

the pokemon so we're gonna go here and

play03:34

make sure it's dot net six because

play03:36

that's the newest one that's kind of the

play03:37

one that you wanna start working on if

play03:39

you're a beginner so that by the time

play03:40

you do get a job you'll be really good

play03:42

at dotnet six make sure open api support

play03:45

is enabled because that is what's going

play03:47

to give you swagger

play03:49

you could

play03:50

just do http but for https

play03:53

i would just go ahead and do that

play03:55

because

play03:55

visual studio is going to handle

play03:57

everything for you make sure use

play03:58

controllers is checked and we're going

play04:00

to go ahead also make sure

play04:02

authentication is none we'll add

play04:04

authentic authentication later

play04:06

so

play04:08

just to kind of get you going the way

play04:10

that you actually start the app is you

play04:12

click this green button right here

play04:14

that's going to go ahead and spin up a

play04:16

web page

play04:18

uh normally i don't think in the past

play04:21

i think it spun up a web page but i

play04:23

don't think like i actually don't really

play04:25

know what it used to but for these

play04:28

purposes nowadays whenever you click

play04:30

that green button in.net 6 you're going

play04:33

to get a swagger screen it's going to

play04:35

like i said give you a nice little gui

play04:37

so that you can look at all of your api

play04:39

endpoints and you won't get confused

play04:41

because postman you have to set

play04:43

everything up but swagger just kind of

play04:44

automates everything and makes

play04:45

everything really easy so

play04:47

unless you're working in a professional

play04:49

environment i would just go with swagger

play04:51

but you i you could use postman if you

play04:53

wanted to

play04:55

all right so whenever you click on that

play04:57

it's going to close out of the app it's

play04:59

going to shut down the actual app and

play05:02

i'll just go ahead and go through here

play05:03

so usually the solution explorer is over

play05:05

on this side but i like to put on that

play05:07

side because it just looks more i don't

play05:10

know vs code like

play05:12

um

play05:13

so a solution many times people are

play05:15

confused about solution a solution can

play05:18

hold multiple projects so if we had

play05:20

multiple apis within our same project

play05:23

you could do that with a solution and

play05:25

that's kind of like what the idea is for

play05:27

a solution but in this case we're not

play05:29

going to um

play05:31

be utilized like solutions to their

play05:33

fullest extent because we only have one

play05:35

project

play05:36

uh let's go like into our actual project

play05:38

i'll tell you what you need and what you

play05:40

don't need so you don't need to learn

play05:42

anything about connected services you

play05:44

don't need to learn anything about

play05:46

dependencies

play05:47

you need to learn what launch settings

play05:49

json is

play05:51

so launch settings json is kind of the

play05:53

way it sounds it's settings for when the

play05:55

app actually launches and you have two

play05:58

settings um you have just a regular app

play06:01

settings which is going to handle

play06:03

uh what is actually going to go on when

play06:06

the app is actually running and then you

play06:08

have launch settings which once again

play06:10

have it's kind of the way it sounds you

play06:13

are going to configure how the actual

play06:15

app launches

play06:17

so got those two knocked out we can just

play06:20

go ahead and delete this uh weather

play06:23

forecast right here we don't even need

play06:24

this and we don't need our controller

play06:27

either

play06:28

microsoft puts like a a dummy weather

play06:30

forecast controller and you may have

play06:32

seen it when we were in swagger but it's

play06:34

really just a way to demonstrate like

play06:37

what the capabilities are

play06:39

uh where stuff is and that's kind of

play06:40

like the reason they put it in there but

play06:42

you don't even really need it

play06:44

all right so

play06:45

probably the most important uh file of

play06:49

all of them is going to be our

play06:50

program.cs

play06:52

think of the program.cs is like

play06:55

the main settings like there's you know

play06:57

obviously there's the app settings to

play06:59

json but this the program file is where

play07:01

you're going to kind of like wire in a

play07:03

bunch a bunch of functionality so

play07:06

uh look at it in two parts you have this

play07:09

stuff up here

play07:12

and then you have all of this stuff down

play07:14

here

play07:15

and the way that microsoft used to do it

play07:18

was

play07:18

this stuff up here is like literally

play07:20

where you just wire in functionality

play07:22

let's say if you wanted to add like

play07:24

database support you would just kind of

play07:25

like wire it in to here and you would be

play07:29

able to access your database or it would

play07:31

provide the functionality for it so

play07:33

whenever you're using some type of

play07:35

module or if maybe if you're using like

play07:37

identity framework if you're using

play07:38

entity framework that's actually where

play07:40

you're going to kind of like install it

play07:42

and

play07:43

just think of that as like what services

play07:45

are and you can see here we've installed

play07:47

swagger we've installed we've installed

play07:49

our controllers it's not really called

play07:50

installing but you know you kind of get

play07:52

the picture you're you know

play07:54

downloading some type of code into your

play07:56

app and you're just you know inserting

play07:58

it into it then you have stuff like this

play08:00

down here

play08:02

this is more middleware

play08:04

so middleware can be described as this

play08:07

whenever you send an http request to

play08:09

something it goes through almost like a

play08:12

car wash like a technological car wash

play08:15

it's not a real car wash of course but

play08:17

it's almost like technological like you

play08:19

go through a car wash and it sprays soap

play08:20

on the car and then it spray you know it

play08:23

blows hot air on the car and then it

play08:25

does all these things to it to clean

play08:26

your car

play08:27

this is kind of like this but in web

play08:30

development so you're going to send like

play08:31

an http request and as this http request

play08:34

goes through the actual app it's going

play08:36

to kind of like

play08:38

blow you know

play08:39

hot air on it but or it's going to do

play08:41

things like authorization you're going

play08:44

to do https redirection it's going to

play08:47

check if they're swagger and it's going

play08:48

to kind of do things sequentially as

play08:51

well too that's like another key point

play08:52

that's why i use the analogy of the car

play08:54

wash it's kind of like a sequential you

play08:56

know thing that you have to do

play08:59

um many people are often confused like

play09:02

what is like an api like why do we even

play09:06

why do we even need apis

play09:08

apis are very important and this is the

play09:11

best way i've ever heard an api

play09:14

explained

play09:15

it's very elegant but people are going

play09:17

to argue about this and people are going

play09:19

to say i'm an idiot and somebody's going

play09:20

to add me on twitter to like try and get

play09:22

in like start a twitter fight with me

play09:24

but

play09:25

the way that the best way i've just

play09:27

heard uh apis described is that it's sql

play09:31

over http

play09:33

so let me elaborate on that a little bit

play09:35

if you

play09:37

google is a huge company with tons and

play09:39

tons of valuable data and one day you

play09:42

too will be working with for a company

play09:44

that is storing tons and tons of

play09:46

valuable data and

play09:48

you can't send sql over the internet

play09:51

like it's just not designed for it so

play09:54

you have

play09:55

code on top of a sql database

play09:59

and this c sharp code is going to make

play10:01

it so that people can you know

play10:03

intuitively access your data through

play10:06

things called endpoints which are

play10:08

basically http or

play10:10

urls and it's going to give people a way

play10:13

that they can grab the data that they

play10:15

need through these urls so in theory

play10:19

like if we just went back to you know

play10:21

swagger

play10:23

you can see that these things are urls

play10:25

and it's tied to kind of like this noun

play10:28

or like this

play10:29

this object or it's tied to our database

play10:32

tables and

play10:33

that's just a url that is going to allow

play10:36

us like i said to access

play10:38

data in ways that we see

play10:40

you know we deem appropriate like and

play10:43

look at it like this like if i just go

play10:44

to this i think i should okay yeah this

play10:47

is like the data in

play10:49

this is what an api is actually

play10:51

returning it's returning json and it's

play10:54

not beautiful it's not pretty but it's

play10:56

returning the exact data that we need

play10:59

and it's returning in a way that you

play11:01

could quickly do something with it like

play11:03

you could display this in react and you

play11:05

could just you could you know maybe

play11:07

download this to your other database and

play11:08

you could have ways that programs are

play11:10

communicating and that's like the whole

play11:12

entire idea of apis it's a way that

play11:15

programs can communicate with each other

play11:17

in ways that are intuitive secure and

play11:20

allow people who are kind of like

play11:22

strangers to your database to access

play11:24

information

play11:26

you know the data that they need so that

play11:28

they can be productive

play11:29

and

play11:30

that is pretty much it that that's about

play11:32

as much as i can go into apis the rest

play11:34

of it you're pretty much just going to

play11:36

kind of have to intuitively learn on

play11:38

your own it's going to be a process it's

play11:40

not going to be you know learning apis

play11:43

is kind of uh

play11:44

like to a certain extent drudgery

play11:46

because you don't know what's going on

play11:47

but if you just keep with it you just

play11:48

keep going it will eventually make sense

play11:51

and you'll get a job in no time because

play11:53

the demand is totally there there's tons

play11:56

of asp.net web api jobs there's tons of

play11:58

opportunity

play12:00

jobs waiting for you at the other side

play12:02

anyway i hope that you guys enjoyed this

play12:04

if you did make sure to hit that like

play12:05

button make sure to hit that subscribe

play12:07

button and as always thank you for

play12:09

watching

Rate This

5.0 / 5 (0 votes)

Related Tags
ASP.NETWeb APIC#TutorialBeginnerAPI DevelopmentSwaggerRESTfulProgramming.NET 6