Part 6 Creating first Web/REST api service or endpoint || Asp.Net Core Web API Tutorials C#

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
tutorials I am venkat this is part 6 creating first web API service so in this entire series I am going to use Microsoft Visual Studio 2022 and if you want to create your first vbpi endpoint we need to create the web API project first for that I have opened the visual studio 2022 and this screen will be showed up left side you can see all your recent projects and right side you can see the options to create a project or open a project like that so from that four options you can click on create a new project option and it will load all the templates left side all the recent templates I have used right side is the list of templates available as part of this Visual Studio installation okay from this list of templates we need to select asp.net core web API template this is the template if you cannot see this template you can also search that search with web API you can find that in the list so aspirotment core web API this is for C sharp programming language once you select that one click on next it is asking for your project name give the project name I am giving it as a college app click next and select the framework.net 6.0 is the latest framework I have installed I'm selecting that and Link the rest of the configurations click on create yeah my project got created web API project and these are the controllers I have I wanted to remove the existing controllers so I'm cleaning up the project okay so this is the program.cs this is the place where I'll do all my web API related configurations we are going to discuss about this this is the settings file configurations so we can put all the configurations related to this project here and this is the controllers folder let's add the controllers okay so if you want to add a controller you just need to right click on controllers folder and go to add click on a class I'm adding a class now so name your class as a student controller click on ADD so I got the student controller class added and if I need to enable this class as a controller class I need to inherit from controller base this controller base requires a namespace to be added we need to add API controller as we are building the API application also this needs the route this is the route API slash and our controller is ready let's build one endpoint Public public strength get student name returns student name one just for now I'm just returning the static data this is the my first controller and this is my first endpoint I have created Let's test it if you want to run the application you can see this green color play button you can click on that or you can simply hit F5 from your keyboard I'm clicking on this button it is building once the build is succeeded then it will opens up the browser so we can see there are errors showing up that error is because we did not mention any HTTP attribute for this that's why it is saying error so I want to mention this as a HTTP gate so now let's run it again now you can see there is one endpoint student endpoint and it has one action we can also test it from this Swagger UI I clicked on that right and click on execute so we got the response back so student name one that's the data we are returning okay this is the student name this is the first endpoint we have created but in future we are not going to return a simple string we are going to return the full student details okay so just now we have added it by using the class right there is another option to create a controller so right click on this click on ADD there is a controller option this is disabled because this project is running let's stop the project right click on controllers and click on ADD now you can see the controller option is enabled click on the controller what type of controller we wanted to add MVC controller or VBA controller we wanted to add API controller okay from the list of controller select the controller you want for now I want the empty controller API controller empty and click on ADD and it will ask the controller name I'll leave it as it is if you if you observe now so when we were adding the controller using a class option it did not add all these additional things when we are adding this one using a controller template it knows that we are creating a API controller we have clearly selected the API controller template that's why it added all the required things when it is creating the controller okay that's the advantage of creating the controller from the template instead of a class okay from this point onwards we are going to use the controller template to add the controller for more videos like this please like share and subscribe thank you
Info
Channel: Nehanth World
Views: 9,645
Rating: undefined out of 5
Keywords: Part 6 Creating first web api service or endpoint || Asp.Net Core Web API Tutorials, web api, c#, tutorial, asp.net core
Id: TbcG-q6hKHQ
Channel Id: undefined
Length: 6min 59sec (419 seconds)
Published: Mon Nov 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.