Creating Asp.net Web API and consuming web API through HTML clients – Part II

Howdy Readers,

Consuming web API through HTML clients

In my previous post we have seen how to create ASP.NET Web API. If you aren’t still comfortable in creating Web API then I would suggest you to read my post for creating Web API.

Today, we will be focusing on consuming web API through HTML clients. Trust me guys, it’s very easy to consume web API and we will do that using JQuery. If you are unfamiliar with JQuery then please refer w3 schools for getting some basic idea about it. Latest version of Jquery can be downloaded from here.

Modify the default file “index.cshtml” in the View/Home folder with the following Markup to provide a GUI for Displaying Products and their different actions.

consuming web API through HTML clients

Creating ASP.NET Web API and consuming through html clients – 1

Now add the following script tag just after the </body> (closing body tag) to call web API

Below are the screenshots for viewing all the products or finding a specific product. Similarly, you can delete a product from the list by specifying its ID or add a new product.

consuming web API through HTML clients

Creating ASP.NET Web API and consuming through html clients – 2

 

consuming web API through HTML clients

Creating ASP.NET Web API  and consuming through html clients – 3

Hurrah! now you have knowledge of creating ASP.NET Web API and consuming it through HTML Clients. Don’t keep it to yourself. Please feel free to share your knowledge among your friends or colleagues.

What do you Think ?

Dear Reader,
If you have any questions or suggestions please feel free to email us or put your thoughts as comments below. We would love to hear from you. If you found this post or article useful then please share along with your friends and help them to learn.

Happy Learning 🙂