Author: Code Maze

State Management in ASP.NET Core MVC

HTTP is a stateless protocol. HTTP requests are independent messages that don’t retain user values or app state. We need to take additional steps to manage states between the requests. In this article, we are going to look at various approaches to preserve user data and app state between the requests.

Read More

Views, Partial Views, and Layouts in ASP.NET Core MVC

In the MVC pattern, Views handle the application’s data presentation and user interaction. They also help to establish a Separation of Concerns (SoC) within an MVC application by separating the user interface markup from other parts of the application. A view is an HTML template with the embedded Razor markup. It has the .cshtml extension and is based on C#. Razor markup interacts with HTML markup to produce a web page which is then sent to the client. Usually, there are separate view files corresponding to each controller action method and view files are grouped into folders named for...

Read More

Getting Started with ASP.NET Core MVC

In this article, we are going to look at the basics of building an ASP.NET Core MVC web app. We are going to start by creating a simple ASP.NET Core MVC app using the default template provided by Visual Studio. The default template itself will translate into a working app. To the default template, we’re going to add a controller and a few action methods. Afterward, we’re going to introduce the views using the razor syntax and return them from the controller methods. Finally, we’re going to define some models and see how those can be passed into the...

Read More

Using C# and DalSoft.RestClient to Consume Any REST API

This post is going to take you through using the DalSoft.RestClient C# library to consume a RESTful API. We are going to show you the most common scenarios using live examples from the REST API JSONPlaceholder. We are using JSONPlaceholder because it’s a great tool for testing REST clients without requiring registration or standing up your own REST API. In this post you’ll learn: What is DalSoft.RestClient? Setting up DalSoft.RestClient What does DalSoft.RestClient Offer? Understanding the DalSoft.RestClient convention HttpResponseMessage and body ToString() Query Strings Headers How to Write Get, Post, Put/Patch, and Delete Requests Casting and Serialization Casting Collections Serialization...

Read More