I would like to use WebAPI for an existing project of mine (classic ASP.NET), but as far as I can tell you can only use WebAPI with MVC.
Is it possible to use WebAPI with ASP.NET?
An API is supposed to provide services without being coupled with its consumer application. There is a common misconception that for developing Web APIs, we have to go by ASP.NET MVC application. In this article, we will develop an independent API which is not coupled with a ASP.NET MVC application type.
Asp.Net MVC is used to create web applications that returns both views and data but Asp.Net Web API is used to create full blown HTTP services with easy and simple way that returns only data not view.
From the linked page:
Although ASP.NET Web API is packaged with ASP.NET MVC, it is easy to add Web API to a traditional ASP.NET Web Forms application. This tutorial walks you through the steps.
To use Web API in a Web Forms application, there are two main steps:
Add a Web API controller that derives from the ApiController class. Add a route table to the Application_Start method. Create a Web Forms Project
Start Visual Studio 2010 and select New Project from the Start page. Or, from the File menu, select New and then Project.
In the Templates pane, select Installed Templates and expand the Visual C# node. Under Visual C#, select Web. In the list of project templates, select ASP.NET Web Application. Enter a name for the project and click OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With