.net core web API tutorial | Web API

Become expert developer by learning all the basics of a secured web API development using .net Core Web API


Here demonstrating web API through Net core. A beginner will be an Expert after going through this Web API tutorial. ASP.NET Core supports in building RESTful services, which is also known as web APIs, using C#. For the purpose of handling requests, a web API utilizes controllers. The controllers in a web API are classes which are obtained from ControllerBase. Here you’ll learn how to employ controllers for good treatment of web API requests efficiently.
Before move ahead, you may need to go through few important topics API essential components as below:

Technology required 

.NET Core, Visual Studio 2017 with last update or Visual Studio 2019, SQL Server

Skills - 

C#, ORM (Object Relational Mapping), RESTful services
Free Video: .Net Core Web API Tutorial  

Following Topics are Covered in this article

  • .Net Core Web API
  • .Net Core EntityFramework
  • .Net Core Depedency Injection
  • Routing

Step By step create a project of Web API: .net core web

Let's develop a Web API with ASP.NET Core 2.1 with Entity Framework Core.

Step #1: Create .Net Core Project From Scratch

Open Visual Studio and then Click on File >> New >> Project , Create New core project by selecting Core Web Application Visual C# from .NET core section and Save with TC.WebAPI, then finally click on OK.

new project Web API

Step #2: Create API Project

Then you'll navigate to next option where you need to select the API icon, click on check box (Configure for HTTPS) option and click on OK to complete the procedure.

.Net Core Web API New Project

Step #3: Create a New Project for Context

Create and define another project for adding Class library.

Add new project >>> from .Net Core section and select type Class library (.NET Core) Visual C# and save as TC.Context and click on OK. Now Context layered created for entity frameowork project.

.Net Core Web API Context Project

Step #4: Create Model

Now, create a TC.Model project and click finally on OK button.

new project Web API TC Model

Step #5: Install Nuget package entity framework

Install & define Nuget package entity framework context as follows.

nuget package entity framework

Step #6: Core DB context

Rename the Class1.cs as Define Name space TCCoreDBcontext.cs. Declare Core DB context class.

.Net Core Web API Context Core DBContext

Step #7: Create a new layer for Busines Logic (TC.Service)

Create Next Project >>>  TC.Service >>> for writing business logic in your project as follows:

new project TC Service

Step #8: Data Service & Infrastructure

Now you can check >>> Dataservice >>> Infrastructure folder available under TC.Service layer to write business logic.

data service infrastrcture

Step #9 Entity Framework Configuration

You can see here entity framework configuration >>> TCCoreDBContext with DbContextOption and OnModelCreating (Modelbuilder modelbuilder) function and SaveChanges method.

core entity framework


.Net Core Web API has been introduced wonderful features to make your application more scalable, secure and awesome on network. .Net core also introduced key features to make your Web API more secured across the network.

Download Source coode here >>> Source Code .Net Core Web API 

Suggested Reading


Anjan kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment: