When working with ASP.NET Web Forms applications, integrating with modern Web APIs is a common requirement. Whether you’re consuming internal APIs or third-party services, you may want to retrieve and display API data on an .aspx page. This article walks you through how to call Web API from an ASPX page and process the response using C#.

Project Scenario

You want to make an HTTP request (GET or POST) to an external or internal Web API from your ASPX code-behind (C#), read the response, and optionally deserialize the result (e.g., JSON).

Prerequisites
  • ASP.NET Web Forms application (.NET Framework)
  • A publicly accessible or internal RESTful API
  • Basic knowledge of HttpClient and JSON
  • Install-Package Newtonsoft.Json
Step-by-Step Implementation

Create a login page ASPX Page (Front-end UI)

Code-Behind (Login.aspx.cs)

Call Web API from an ASPX Page

 

Leave a Comment