Thoughts on .Net & Coding
.Net Articles, tutorials, reviews, code and more...
-
Utilize ASP.NET Core Application Lifetime Events
At times you need to know when your ASP.NET Core web application is being started and shutdown. One of the lesser known features of ASP.NET Core is the IApplicationLifetime interface that allows you to wire some logic when such application lifetime events occur. This article briefly discusses the IApplicationLifetime interface and its functionality.
-
Class library projects : .NET Framework, .NET Core, and .NET Standard
Recently Microsoft announced the release of .NET Standard 2.1. You might have already noticed different project templates in Visual Studio 2017 that allow you to build class libraries such as .NET Framework class library, .NET Core class library, and .NET Standard class library. As a beginner you might have wondered what exactly is the difference between them. To that end this article briefly explains each of these three types of class libararies.
-
Use Eager, Explicit, and Lazy Loading in Entity Framework Core
You might be aware that Entity Framework Core 2.1 has added support for lazy loading of navigation properties. This means now we have three ways to load data in the navigation properties - eager loading, explicit loading, and lazy loading. This article summarizes all the three options with an example.
-
Reuse UI with Razor Class Libraries (RCL) in ASP.NET Core
Developers always look for ways to reuse their code and markup. ASP.NET Core offers several ways to reuse code and markup within a project (partials, custom tag helpers, view components etc.). What if you want to reuse a piece of user interface (UI) across multiple web applications? Luckily, ASP.NET Core 2.1 introduced what is known as Razor Class Library (RCL) projects that can be used to accomplish this task.
-
Use [Controller] and [NonController] Attributes in ASP.NET Core
ASP.NET Core MVC uses certain conventions when it comes to naming the controllers. Although these defaults work as expected in many cases, at times you may want to take charge of the controller naming. Luckily, ASP.NET Core provides two attributes - [Controller] and [NonController] - that can be used to alter this default behavior. To that end this article shows how to use these attributes with simple examples.
-
Upload Large Files in ASP.NET Core
By default, ASP.NET Core allows you to upload files approximately 28 MB in size. However, at times you want to deviate from this limit and upload larger files on the server. To raise this limit you need to make a couple of additions to your code. And there are a few variations of how that can be done. To that end this article discusses these possible approaches to upload large files.
-
Automatic Model Validation and Parameter Binding using ApiController Attribute
While developing ASP.NET Core Web API you need to perform model validation manually. You also need to bind action parameters explicitly using attributes such as [FromBody]. The [ApiController] attribute introduced in ASP.NET Core 2.1 can automate both of these tasks for you. This article explains how.
-
Use Angular Component as Element, Attribute, and Class
Components are building blocks of any Angular application. Most commonly Angular components exist as custom markup elements in the template. However, that's not the only way to use components. You can also use them as if they are an attribute of an HTML element. Or you can also use them as the value of class attribute on HTML elements. Using Angular selectors you can decide how a component will be used in the template markup. To that end this article illustrates each type of usage with a simple example.
-
Understand the difference between AddMvc() and AddMvcCore()
As a beginner, you must have stumbled upon these two methods - AddMvc() and AddMvcCore() - in the ConfigureServices() of the Startup class. you must have wondered about the difference between them. This article quickly points out the difference between the two.
-
Create Custom Client Side Validation Attribute in ASP.NET Core
ASP.NET Core comes with a set of validation attributes that can be used to perform basic validations in your application. At times the inbuilt validation attributes doesn't meet your requirements and you need something customized as per your validation criteria. Luckily, you can easily create your own validation attributes that perform client side as well as server side validations. This article shows how.