Contents tagged with Web API
-
Dealing with JSON serialization and camel casing in AspNet Core
ASP.NET Core Web APIs and controllers often need to serialize JSON data to JavaScript clients. On the server side your C# classes typically use Pascal Casing to name properties whereas JavaScript code often uses Camel Casing for property names. Therefore it would be worthwhile to take a quick look at how ASP.NET Core serializes data in JSON format from Web API and MVC controllers.
-
Create a TypeScript class to invoke ASPNET Core Web API
In the previous part of this series you learned about TypeScript functions. Now it's time to peek into some more interesting features. To that end, this part discuses three of them - interfaces, classes, and inheritance. You will build a fully functional class that helps you invoke an ASP.NET Core Web API. You then perform CRUD operations using the class developed in this exercise.
-
Push data to client using ASP.NET Core Web API and Server Sent Events
Server Sent Events or SSE allow you to send push messages from the server to client. They come handy when you have a lengthy processing going on the server and want to notify the client from time to time about the status or intermediate results of the processing. In this article you will learn how SSE can be used to push data from Web API to the JavaScript client.
-
Three ways to return data from ASP.NET Core web API
ASP.NET Core allows you to build RESTful services using web API. Typically you want to return data and HTTP status codes from an API controller. To that end there are three ways to return values from an API controller. This article discusses them with an example.
-
Enable CORS in ASP.NET Core API
Browsers do not allow cross origin communication for security reasons. This means if an ASP.NET Core web API housed in one web app is called by JavaScript code running as a part of another web app, the communication attempt will fail. However, you can alter this default behavior by adding some configuration in your API application. To that end this article discusses how that task can be accomplished.
-
Use XML format with ASP.NET Core web APIs
In one of my past articles I discussed how to deal with XML data in ASP.NET Web APIs. Although JSON is quite popular format in API communication, at times you might need to handle XML data. To that end this article describes the required configuration with a simple example.
-
Implement JWT Authentication in ASPNET Core APIs
If you developed web applications using ASP.NET before, chances are you are already familiar with cookie authentication. Although cookie based authentication is still available under ASP.NET Core, JSON Web Token or JWT based authentication is becoming more and more common. To that end this article aims at introducing you to JWT and JWT based authentication.
-
Multiple GET and POST methods in ASP.NET Core Web API
In ASP.NET Core MVC and Web API are parts of the same unified framework. That is why an MVC controller and a Web API controller both inherit from Controller base class. Usually a Web API controller has maximum of five actions - Get(), Get(id), Post(), Put(), and Delete(). However, if required you can have additional actions in the Web API controller. This article shows how.
-
Use Cookie Authentication with Web API and HttpClient
Recently I wrote this article explaining the cookie authentication in ASP.NET Core. A reader asked whether cookie authentication can be used with ASP.NET Core Web API and that too when the Web API is being consumed using HttpClient component. This article explains a possible solution to the problem.
-
Use Razor Pages, MVC, and Web API in a single ASP.NET Core application
If you are worked with ASP.NET Core 2.0 before you are probably aware that Visual Studio 2017 offers three basic project templates for creating ASP.NET Core 2.0 projects. They are Web Application (Razor Pages), Web Application (MVC), and Web API (see below). Interestingly Web Application project defaults to Razor Pages. It is important for the beginners to be aware that although these are three different project templates, you can have all these development options - Razor Pages, MVC, and Web API - inside a single ASP.NET Core web application.