Before ASP.NET Web API core, the two-different framework MVC and Web API were pretty much similar. Both used to support Controller and action methods. In earlier version, the main purpose of Web API was to make REST API calls and there were view engine like Razor. On the other hand, MVC was designed for HTML front ends to communicate to backend in a standard a web application. However, when ASP.NET Web API core was released, the main target was to support JSON based REST API. It combines the key feature of both MVC and old Web API framework.
- ASP.NET Core Web API Tutorial – Part 2 continues the tutorial series with practical implementation of ASP.NET Core Web API with all CRUD (Create, Retrieve, Update, Delete) Operations.
- ASP.NET Core Web API Tutorial – Part 3 covering Web API Security Architecture, How to setup an authentication filter? and more.
ASP.NET Core Web API Architecture
ASP.NET Web API is mainly based on the MVC architecture. In below figure, it shows that current .NET framework supports both ASP.NET 4.6 and Core 1.0, recently Core 2.0 has been released. Core framework can be deployed in different OS platform. And the underline compilers and run time library accessible by different OS deployment. The .NET framework and .NET Core also share a number of APIs.
Fig [2] shows that the main component of ASP.NET Core is the MVC 6 which has included Web API and WEB View. Another important component is the SignalR, this is a library that simplifies the process of detecting real time changes on a web application and perform action based on the changes. As soon as the data in server is updated client would get the updated data.
SignalR provides a simple API to make server-to-client remote procedure calls (RPC) that invoke JavaScript functions in client browsers once the data in server is changed from server. SignalR also provides API for connection management and grouping connections.
The next important component for ASP.NET is the EF Core. Entity Framework Core is a lightweight, extensible, and cross-platform solution for entity framework data access technology. This has been released with ASP .NET Core in order to support its cross platform deployment. This is also an object-relational mapper (O/RM) that config the mapping between database object and .NET object model. Therefore, developer does not need to code for the data-access layer.
New Features available in ASP.NET Core Web API
Cross Platform
ASP.NET Web API Core is cross-platform; therefore, it is suitable for running on any platform like Windows, Mac, or Linux. Earlier ASP.NET applications were not able to run on Linux and Mac operating system.
Backward Complatibility
For existing application, ASP.NET Web API Core supports two framework.
Faster
ASP.NET Web API Core is much faster than previous versions.
Static Content
wwwroot folder contain all the static content e.g. js, css, images.
- Build a full-stack web app with ASP.NET Core, Entity Framework Core and Angular 2 & 4.
- Implement a Clean & Decouple Architecture.
- Properly implement the Repository and Unit of work patterns.
- Troubleshoot common runtime errors.
- Test APIs using PostMan.
- Integrate ASP.NET MVC/Core with AngularJS.
- Understand and apply the Dependency Inversion Principle (DIP).
- Use the new dependency injection feature in ASP.NET Core.
- Build APIs with ASP.NET Core
- and more….
Razor Pages
There is the new view engine, Razor Pages (new in 2.0) is a page-based programming model. As most of the web sites are usually a collection of multiple web pages., this engine is very helpful for developing web applications faster and more efficiently .
Recently ASP .NET Core 2.0 has been released with some more feature,. In a summery we can say the following are the key feature for ASP .NET Core Web API
- A modern framework for developing web UI and web APIs in the same application.
- Modern client-side frameworks and development workflows has been integrated.
- Configuring a complete integration and cloud based deployment is very easy and flexible.
- It provides Built-in dependency injection.
- This is a lightweight, high-performance, and modular HTTP request pipeline.
- Its help to host on IIS or to self-host inside the application process.
- It is possible to run on .NET Core along with traditional ASP .NET.
- Tooling has been simplified to a great extent for being efficient enough for modern web development. Adding a MongoDB Drive is just few click action to be done.
- Cross platform support.
Comprehensive Step by Step Example using Fiddler Tool to Consume a RESTful Service
Fiddler is a very popular debugging as well as performance evaluation tool for REST API call among developers. Fiddler is a powerful debugging proxy to Test REST API call as loges everything between local server and internet and inspects the traffic and every incoming and outgoing data. As this is a debugging proxy, it allows to set breakpoint to identify potential issue, scalability and eventually helps to evaluate the performance for the application.
Fiddler Key Features:
- Fiddler can be used to debug web traffic from any platform, e.g. Windows-based PC, Mac or Linux system, mobile devices on both ios and android.
- Fiddler can capture traffic from remote computers and network devices that support proxy servers.
- Fiddler supports any client which is pretty much any browser.
- Fiddler can decrypt HTTP traffic.
- Fiddler helps to analyze the response and request data with so much flexibility using a very rich tools.
- One of the major purpose that developer uses fiddler tool is to evaluate the performance of the application. Fiddler timeline view give extensive information for the performance evaluation.
- Fiddler can even filter out interested traffic.
- It is even possible to set the GEO location in order to analyze the traffic for a particular geo location.
- The list of filter option is very rich.
Step by Step Live Example:
- Download fiddler from here.
- Install fiddler to the PC.
- Open Fiddler.
- Right click the process from the left side explorer and Select Filter Now> Show only Process <processId>.
This will only show the process that we are interested of.
In order to use a third party application , for this example we would use the api from https://randomuser.me/ - Compose API
- Click on the ‘Compose Tab’
- Type ‘https://randomuser.me/api/?results=50’ URL
- Set method as GET
- Add ‘Content: application/json’
- Hit Excecute
- Inspect Response
-
- The response would be
-
- Click on the ‘Inspector Tab’
- Click ‘Headers’
-
- Click on the Syntax View
-
- Select JSON
-
There are many other uses of fillder application for checking caching, authentication, network performace and so on.
You can follow below for more helpful material regarding related technologies here:
- ASP.NET Core Web API Tutorial – Part 2
- ASP.NET Web Forms – Beginners to Professional
- All about ASP.NET MVC
- Practical Guide to ASP.NET Web API