ASP.NET Core 2.1 introduced the APIController
attribute which performs automatic model state validation and in case of an invalid model state, responds with a 400 bad request error. When the controller is decorated with APIController
attribute, the framework would automatically register a ModelStateInvalidFilter
which runs on the OnActionExecuting
event. This checks for the model state validity and returns the response accordingly. This is a great feature, but sometimes you want to return the custom error instead of the 400 bad request error. In such case, we should disable automatic model state validation.In this post, find out how to disable automatic model state validation in ASP.NET Core 2.1.
ASP.NET Core 2.2 introduces API Analyzers for improved WEB API documentation
One of the new features of ASP.NET Core 2.2 is, API Controller conventions for better documentation experience. ASP.NET Core 2.1 introduced the ApiController
attribute to denote a web API controller specific conventions like performing automatic model validation and automatically responds with a 400 error. The ASP.NET Core 2.2 takes one step further to provide the metadata for API Explorer and a better end-to-end API documentation experience. To achieve this, ASP.NET Core 2.2 introduces API Analyzers which help in following a set of conventions for better API documentation. In this post, let’s find out how to use API Analyzers. Read More
How to lazy load images in Angular 6
Lazy loading is a technique to load the content only when the user asks for it. Therefore, the initial loading of the webpage is much faster as the complete page is not loaded. In case of lots of images on the webpage, it is always recommended to use lazy loading for the images. As an example, while showing a photo gallery, there is no point loading all the images in one go as the user may leave after only viewing the first few images and this would result in slower loading and waste of bandwidth. In such scenarios, lazy loading is an ideal choice. This post talks about how to lazy load images in Angular 6.
Read More
A neat way to build query string in ASP.NET Core
Creating query string in code can lead to errors as you have to deal with strings, ampersand and question marks. Fortunately, ASP.NET Core has a static class QueryHelpers
which has a function called AddQueryString
offers a neat way to build query string in ASP.NET Core. The AddQueryString
method has 2 definitions. One for creating query string for single parameter and another for multiple parameters. Read More
FromServices Attribute in ASP.NET Core
ASP.NET Core has inbuilt support for the dependency injection (DI) for adding the dependency to the container and then consume it in our application. Constructor injection is a familiar, and the most used way to inject the dependencies. However, it may not be an ideal choice in certain situations like only a single action method within the controller requires the dependency. ASP.NET Core provides an attribute called FromServices
to inject the dependencies directly into the controller’s action method. In this post, we’ll find out how to use FromServices Attribute in ASP.NET Core. Read More
Angular Console – An UI for Angular CLI
When Angular CLI was released, it instantly got the attention, and many developers started using it as it took away all the pain to create Angular based applications. Angular CLI performs every activity required for an angular application starting from creating to deploying the app. You don’t have to spend time for webpack configurations, making tests run, fixing source maps as the CLI takes care. But, one will have to remember all the CLI commands to use it efficiently. To address this, a new tool is available called “Angular Console”. It’s a visual representation of angular CLI. In this post, we’ll see how to get started with Angular Console and create an angular application using the same.
Read More
Angular 6.1 introduces a new KeyValue Pipe
Angular 6.1 is out and it introduces a new KeyValue
pipe to help you iterate through objects, maps, and arrays. Today, the ngFor
directive doesn’t support iterations over objects or Maps. To fix this issue, Angular 6.1 introduces a new KeyValue
pipe. The KeyValue pipe converts an Object or Map into an array of key-value pairs to use with ngFor
directive. In this post, we’ll find out how to use this new KeyValue
pipe with Angular 6.1 with examples. Read More