Web API Archives - Code Maze https://code-maze.com/category/web-api/ Learn. Code. Succeed. Fri, 01 Nov 2024 07:44:58 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.5 https://code-maze.com/wp-content/uploads/2020/01/Code-Maze-Favicon.png Web API Archives - Code Maze https://code-maze.com/category/web-api/ 32 32 Conditionally Add Middleware in ASP.NET Core https://code-maze.com/aspnetcore-conditionally-add-middleware/ https://code-maze.com/aspnetcore-conditionally-add-middleware/#respond Fri, 28 Jun 2024 06:32:32 +0000 https://code-maze.com/?p=120165 In this article, we’ll explore different techniques on how to conditionally add middleware in ASP.NET Core applications. Let’s start! Conditional Middleware: Why and When? Conditional middleware in ASP.NET Core is crucial for dynamically adapting our application behavior based on the runtime environment or specific request details. Let’s take a look at the key scenarios where […]

The post Conditionally Add Middleware in ASP.NET Core appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-conditionally-add-middleware/feed/ 0
Using the Result Pattern in .NET Web API https://code-maze.com/aspnetcore-result-pattern/ https://code-maze.com/aspnetcore-result-pattern/#comments Tue, 14 May 2024 04:06:24 +0000 https://code-maze.com/?p=116672 In the expanding world of APIs, meaningful error responses can be just as crucial as well-structured success responses, and here, the Result Pattern can help us greatly. To introduce the Result Pattern, we will go through a series of iterations, presenting different ways of passing information about the success or failure of a given operation. […]

The post Using the Result Pattern in .NET Web API appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-result-pattern/feed/ 2
How to Show Query Parameters in Swagger in ASP.NET Core https://code-maze.com/aspnetcore-show-query-parameters-in-swagger/ https://code-maze.com/aspnetcore-show-query-parameters-in-swagger/#respond Sun, 05 May 2024 10:15:06 +0000 https://code-maze.com/?p=116618 In the .NET ecosystem, Swagger is a common way to define and document our APIs. In this article, we will look at how to show query parameters in Swagger. Let’s make a start. Swagger And Query Parameters Swagger is a framework for designing, documenting, and consuming RESTful Web APIs. It provides us with tools to […]

The post How to Show Query Parameters in Swagger in ASP.NET Core appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-show-query-parameters-in-swagger/feed/ 0
Automatic Registration of Minimal API Endpoints in .NET https://code-maze.com/aspnetcore-automatic-registration-of-minimal-api-endpoints/ https://code-maze.com/aspnetcore-automatic-registration-of-minimal-api-endpoints/#respond Fri, 15 Mar 2024 07:00:13 +0000 https://code-maze.com/?p=109809 In this article, we will explore how we can improve our Minimal API endpoints in .NET with automatic registration. Let’s dive in! Minimal API Setup In this article, we’ll use a Minimal API that represents a basic school system, focusing on two key endpoints: app.MapGet("/students", async (IStudentService service) => { var student = await service.GetAllAsync(); […]

The post Automatic Registration of Minimal API Endpoints in .NET appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-automatic-registration-of-minimal-api-endpoints/feed/ 0
How to Fix CORS Error With AnyOrigin and AllowCredentials https://code-maze.com/aspnetcore-how-to-fix-cors-error-with-anyorigin-and-allowcredentials/ https://code-maze.com/aspnetcore-how-to-fix-cors-error-with-anyorigin-and-allowcredentials/#respond Fri, 01 Mar 2024 07:33:51 +0000 https://code-maze.com/?p=109685 In this article, we will learn how to fix the CORS protocol error with AnyOrigin and AllowCredentials in ASP.NET Core (The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time). We assume you know the basics of CORS and how to use it. If not, let’s quickly refresh […]

The post How to Fix CORS Error With AnyOrigin and AllowCredentials appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-how-to-fix-cors-error-with-anyorigin-and-allowcredentials/feed/ 0
How to Call SignalR Hub from Controller in ASP.NET Core https://code-maze.com/aspnetcore-call-signalr-from-controller/ https://code-maze.com/aspnetcore-call-signalr-from-controller/#respond Mon, 19 Feb 2024 07:03:55 +0000 https://code-maze.com/?p=109554 In this article, we will look at how to call a SignalR Hub from an ASP.NET Core controller. If you are unfamiliar with setting up SignalR in your server and/or client application, check out our article for more information. Let’s begin by pointing out some important information about the SignalR Hub and the IHubContext<T> interface. Overview […]

The post How to Call SignalR Hub from Controller in ASP.NET Core appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-call-signalr-from-controller/feed/ 0
Creating Conditional Required Attributes for Validation in .NET Web API https://code-maze.com/aspnetcore-conditional-required-attributes/ https://code-maze.com/aspnetcore-conditional-required-attributes/#respond Thu, 15 Feb 2024 02:50:36 +0000 https://code-maze.com/?p=109046 Whether seasoned or just getting started in the .NET world, we’ve all encountered situations where we need to conditionally validate some attributes of data based on specific conditions. In this article, we’re going to learn about creating conditional required attributes for validation, and why we need them. We’ll also cover approaches we can use to […]

The post Creating Conditional Required Attributes for Validation in .NET Web API appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-conditional-required-attributes/feed/ 0
Different Ways to Validate an Uploaded File in ASP.Net Core https://code-maze.com/aspnetcore-validate-uploaded-file/ https://code-maze.com/aspnetcore-validate-uploaded-file/#respond Sat, 10 Feb 2024 08:55:39 +0000 https://code-maze.com/?p=109003 As developers, we often tend to oversee the security of our applications. Whether the user misclicks on the wrong file or purposely uploads a malicious one, we should always validate the input loaded through our application. In this article, we’ll look at a few techniques for uploaded file validation in an ASP.NET Core project. To learn […]

The post Different Ways to Validate an Uploaded File in ASP.Net Core appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-validate-uploaded-file/feed/ 0
The Difference Between RESTful APIs and Web APIs Using ASP.NET Core https://code-maze.com/aspnetcore-difference-between-restful-apis-and-web-apis/ https://code-maze.com/aspnetcore-difference-between-restful-apis-and-web-apis/#respond Fri, 09 Feb 2024 06:50:18 +0000 https://code-maze.com/?p=107778 In this article, we will discuss the difference between RESTful APIs and Web APIs using the ASP.NET Core framework. We’ll begin by explaining what exactly an API is. Then, we’ll explain the meaning of REST and RESTful. After that, we will delve into Web APIs. Finally, we’ll round things up by summarizing the difference between […]

The post The Difference Between RESTful APIs and Web APIs Using ASP.NET Core appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-difference-between-restful-apis-and-web-apis/feed/ 0
MapControllers vs MapControllerRoute Routing in ASP.NET Core https://code-maze.com/aspnetcore-mapcontrollers-vs-mapcontrollerroute-routing/ https://code-maze.com/aspnetcore-mapcontrollers-vs-mapcontrollerroute-routing/#respond Tue, 06 Feb 2024 11:35:47 +0000 https://code-maze.com/?p=104156 In this article, we will examine the two key routing methods in ASP.NET Core: MapControllers vs MapControllerRoute, and their differences. They are vital in directing HTTP requests to the appropriate controller actions. So, let’s explore the differences and use cases of MapControllers and MapControllerRoute in ASP.NET Core. Difference Between MapControllers and MapControllerRoute Routing Routing is […]

The post MapControllers vs MapControllerRoute Routing in ASP.NET Core appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-mapcontrollers-vs-mapcontrollerroute-routing/feed/ 0