Tuesday, December 1, 2015

Web API in ASP.Net Web Forms - Simple Way

ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
So this is the basic definition of Web API and lets see how we can use it in an ASP.Net Web Forms application. You need to have Visual Studio 2013 or 2015 which may be the community edition.

1. Right click on your project and Add "Web API Controller class" which you can find under
Web > Web API



2. Add a newer folder for API Classes & You may also have a separate project too. Here I have added the classes in to a Folder.

3. You can write API Methods in this controller (Ex: SignOut)


4. Now you can write a JQuery AJAX method to call the API Method.


Remember to use valid error messages for null returns.

Happy coding.. :)


No comments:

Post a Comment