How to handle null values in ASP.Net Core MVC


ASP.Net Core MVC is the .Net Core counterpart of the ASP.Net MVC framework. You can take advantage of ASP.Net Core MVC to build cross-platform, scalable, high-performance web applications and APIs using the Model-View-Controller design pattern.

We always want to handle errors elegantly in our web applications. When it comes to empty responses to requests, or returning null values from the action methods, the ASP.NET Core MVC framework returns HTTP Status Code 204, i.e., the “No Content” response. In this article we’ll examine how we can change this default behavior when the action methods return null values.

To work with the code examples illustrates in this article, you should have Visual Studio 2019 installed in your system. If you don’t already have a copy, you can download Visual Studio 2019 here

Create an ASP.Net Core MVC project in Visual Studio

First off, let’s create an ASP.Net Core project in Visual Studio 2019. Assuming Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new ASP.Net Core project in Visual Studio.



Source link

READ ALSO  Logitech MK470 Slim Wireless Keyboard and Mouse Combo is quiet, elegant, and affordable
?
WP Twitter Auto Publish Powered By : XYZScripts.com