Thoughts on .Net & Coding

.Net Articles, tutorials, reviews, code and more...

  • Use Azure Cache for Redis in ASP.NET Core

    Many ASP.NET Core application resort to caching for performance improvement reasons. I have discussed a few caching techniques in this, this, and this article. Additionally developers also use Azure Cache for Redis. It's a fully managed, high-performance in-memory caching service that you can utilize in your ASP.NET Core web applications. This article shows how.

  • Switch-less code : An Example in ASP.NET Core

    It is common in ASP.NET Core application to store one or more configuration options in appsettings.json. These options are then read inside MVC controllers or Razor Pages page models. Depending on a particular configuration setting you want to execute certain piece of processing. Although it sounds quite simple and straightforward beginners often end up doing this in a not-so-good way. To that end this article discusses a possible approach that is more flexible and helps you reduce the amount of future changes.

  • Authorize users with Azure Active Directory in ASP.NET Core

    In the previous article we discussed how to integrate Azure AD authentication in an ASP.NET Core web application. Continuing from where we left, this article shows how to authorize users based on their AD groups. First of all you need to create required groups in Azure AD and then assign one or more groups to a user account. So, open the Azure AD that you used last time and locate the Groups options as shown below.

  • Authenticate users with Azure Active Directory in ASP.NET Core

    ASP.NET Core web applications often need to authenticate users accessing the application. There are many authentication schemes you can use to accomplish this task. One of them is authenticating using Azure Active Directive (Azure AD). ASP.NET Core project templates provide an easy way to integrate Azure AD authentication in an application. However, there are a few steps you need to perform before going ahead with the integration process. To that end this article explains what those steps are and how to complete the integration.

  • Build your first Blazor client-side application

    In the previous article you learned to build your first Blazor server-side application. In this article you will develop the same data entry form using Blazor client-side application. Blazor client-side applications use WebAssembly (Wasm) to run. A WebAssembly capable browser downloads the Blazor application on the client-side and then executes it within the boundaries of the browser.

  • Build your first Blazor server-side application

    If you are tracking the progress of ASP.NET Core 3, you are probably aware that Blazor is getting a lot of attention and feature improvements. If you haven't developed Blazor applications yet it's worthwhile to take a quick look at the overall development process. To that end this article discusses a simple database update page build using server-side Blazor.

  • Use System.Text.Json for JSON processing in ASP.NET Core

    If you worked with earlier versions of ASP.NET MVC and ASP.NET Core, you are probably aware that these versions use Json.NET library for the sake of JSON processing. In ASP.NET Core 3 Microsoft has provided in-built support for JSON serialization and deserialization. That means you no longer need to depend on Json.NET library. The good part is, you can still use Json.NET if you so wish. So, you have two options now as far as JSON processing is concerned - either use in-built JSON API or use Json.NET. The in-built support for JSON serialization and deserialization comes from System.Text.Json namespace. In this article you will learn to use the System.Text.Json for serializing and deserializing JSON data during Web API communication.

  • Create and Use User Secrets in ASP.NET Core

    While developing an ASP.NET Core web application you often come across pieces of information that you wouldn't like to share with others. Consider, for example, a database connection string that contains a user ID and password. You typically store it in appsettings.json file. But when you share your project code with others (say through a version control system) those details are also shared with others. Another example could be access keys or API keys. You might not want to share these details with others. Luckily, ASP.NET Core and Visual Studio provide an easy way to deal with this requirement through what is known as User Secrets.

  • Multiple implementations of an interface in ASP.NET Core DI container

    If you worked with ASP.NET Core before chances are you used ASP.NET Core's dependency injection features. Most commonly you register a single implementation of an interface as a service type. However, at times you may want to register multiple implementations of an interface as service types. In this article you learn how to accomplish the task.