Archives
-
Use Google Charts in AspNet Core
At time your ASP.NET Core web applications want to display certain data in the form of bar chart or pie chart. Although there are plenty third-party components and libraries that you can use to accomplish this task, Google Charts is a simple yet feature rich client side option. To that end this article shows how Google Charts can be used to render simple bar charts and pie charts.
-
Store images in SQL Server using EF Core and ASPNET Core
At times you need to store images in a data store rather than storing them as physical files. You can store them in and retrieve them from SQL Server using Entity Framework Core and ASP.NET Core. This article shows you how.
-
Use IHttpClientFactory to invoke Web API in ASP.NET Core
If you have worked with ASP.NET Core Web APIs before, chances are you used HttpClient to invoke them. Although instantiating HttpClient directly is a common way of using it, there is a better alternative. Rather than instanting HttpClient yourself you can use IHttpClientFactory to obtain an instance of HttpClient. The HttpClient object thus obtained can be used to invoke the Web API. In this article I discuss three ways to obtain an HttpClient instance using IHttpClientFactory.
-
.NET Standard for Absolute Beginners
If you are a beginner in ASP.NET Core chances are at some point in time you stumbled upon this - .NET Standard. You probably wondered what it is and how is it different than .NET Framework and .NET Core. Although you might have heard this term, while developing your ASP.NET Core apps you might not have bothered about it at all. This might have made you wonder even more as to what's the use of .NET Standard if it's not actively used while developing your apps. You might have also felt bit confusing about the version number that accompanies .NET Standard. This article attempts to explain all these questions about .NET Standard from beginner's perspective. My aim is to quickly enable you to grasp the concept and utility of .NET Standard and I also provide pointers for more detailed understanding.
-
CRUD using gRPC, EF Core, and ASPNET Core (Part - 3)
In Part -1 and Part - 2 of this article you created EmployeeCRUD service definition using Protocol Buffer language and also implemented it in EmployeeCRUDService class. So, our gRPC service is now ready. In this part we will consume the service in an ASP.NET Core MVC application. Begin by opening the GrpcService1 project you created earlier. Add a new ASP.NET Core MVC application in the same solution. Then copy the Protos folder from the GrpcService1 project into the newly created MVC application. At this stage your Solution Explorer will look like this.
-
CRUD using gRPC, EF Core, and ASP.NET Core (Part - 2)
In Part -1 of this article you created EmployeeCRUD service definition using Protocol Buffer language. The EmployeeCRUD.proto file and EF Core model is now ready. In this part you will create the EmployeeCRUD service based on the structure defined in the .proto file. To begin, open the project created in Part -1 and expand the Services folder. Rename the service file to EmployeeCRUDService.cs. At this point the Solutions Explorer will look like this.
-
CRUD using gRPC, EF Core, and ASPNET Core (Part - 1)
If you have read about the new features of ASP.NET core 3.0, you are probably aware that it supports gRPC, a framework for building services using Remote Procedure Call (RPC). I won't go into the dry information about what gRPC is and how it can help you solve software problems in this article. This multipart article creates a simple yet complete example that performs CRUD operations on the Employees table of Northwind database. As you develop this example you will get chance to familiarize yourself with the basics of gRPC as implemented in .NET Core 3.0.
-
Push data to client using ASP.NET Core Web API and Server Sent Events
Server Sent Events or SSE allow you to send push messages from the server to client. They come handy when you have a lengthy processing going on the server and want to notify the client from time to time about the status or intermediate results of the processing. In this article you will learn how SSE can be used to push data from Web API to the JavaScript client.
-
JSON to XML / XML to JSON conversion in .NET Core
JSON is a preferred format for transferring data over the wire in modern web apps. However, at times you need to deal with XML data format. Moreover, you might want to handle JSON and XML in the same application. For example, you might be receiving data in JSON from a Web API and then you might want to feed it to another service that expects input in XML format. Such situations are common when you are integrating old and new software systems.
-
Upload Files Using jQuery Ajax and JavaScript Interop in Blazor
Uploading files from client machine to the server is one of the fundamental operations in web applications. In ASP.NET Core MVC applications you can accomplish this task easily using HTML5 file input field and server side logic. However, Blazor doesn't have any built-in facility (so far) for uploading files. You either need to use some third-party solution or device your own technique to accomplish the task.
-
ASP.NET Core 3.0 - Ten features beginners should know
If you are tracking the progress of ASP.NET Core, you are probably aware that .NET Core 3 and ASP.NET Core 3.0 are being released at .NET Conf 2019. There are many exciting feature additions and improvements to the latest version of ASP.NET Core. You might have already stumbled upon the prominent ones. In this article I am enumerating over ten features / improvements for beginners that are worth noting. My aim is to quickly mention them here so that you can explore them in more detail by visiting Microsoft's official channels such as product documentation and Channel 9.
-
Change Default Location of Views and Razor Pages in ASP.NET Core
ASP.NET Core MVC web applications typically store view files under Views folder and Razor Pages are stored under Pages folder. Although this default location is what you want in most of the applications, at times you may want to store views and pages in some different folder. To that end this short article shows how to accomplish just that.
-
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.
-
Understand InProcess and OutOfProcess Hosting Model in ASP.NET Core
Once you finish developing an ASP.NET Core web application, you need to deploy it on a server so that end users can start using it. When it comes to deployment to IIS, ASP.NET Core offers two hosting models namely InProcess and OutOfProcess. In this article you learn about these hosting models and how to configure them.
-
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.
-
Dealing with MongoDB DateTime in ASP.NET Core
MongoDB is one of the popular NoSQL databases available today. You can use MongoDB database in your ASP.NET Core applications using MongoDB.Driver NuGet package. I discussed the basics of MongoDB including CRUD operations here and here. Document databases such as MongoDB store data as JSON documents. Although JSON supports basic data types such as string, number, and boolean JSON doesn't support DateTime. So, date-time values are stored as string. In this article we will discuss a few things that you need to take into account while storing date-time values.
-
Store and retrieve files from Azure blob storage
ASP.NET Core web applications often need to store files on the server. One of the approaches to storing files on the server side is to store them into Azure blob storage. For example, you can store documents, audio files, video files, and images into Azure blob storage. This article shows you how to add, download, and remove files from Azure blob storage.
-
Reuse UI with Partial Views in ASP.NET Core MVC and Razor Pages
While developing ASP.NET Core web applications you often need to reuse parts of the user interface across many view or razor pages. There are multiple options to address this requirement simplest being Partial Views. In this article you will learn what partial views are and how to use them in ASP.NET Core MVC and Razor Pages applications.
-
Use Cache and Distributed Cache Tag Helpers in ASP.NET Core
Web developers often look for opportunities to boost the performance of their web applications. ASP.NET Core provides server side caching in the form of in-memory and distributed cache implementation. Moreover, it offers two Tag Helpers to implement cache HTML content of razor views or razor pages - Cache and Distributed Cache. To that end this article discusses these Tag Helpers in brief.
-
Handle Unknown Actions in ASP.NET Core MVC
While working with ASP.NET Core MVC, usually you have known number of actions and views. At times you might come across a situation where you need to deal with actions unknown at development time. Let me briefly explain a situation I recently stumbled upon.
-
Three ways to return data from ASP.NET Core web API
ASP.NET Core allows you to build RESTful services using web API. Typically you want to return data and HTTP status codes from an API controller. To that end there are three ways to return values from an API controller. This article discusses them with an example.
-
Enable CORS in ASP.NET Core API
Browsers do not allow cross origin communication for security reasons. This means if an ASP.NET Core web API housed in one web app is called by JavaScript code running as a part of another web app, the communication attempt will fail. However, you can alter this default behavior by adding some configuration in your API application. To that end this article discusses how that task can be accomplished.
-
Reverse Engineering EF Core Model and Data Validation Techniques
While working with ASP.NET Core and Entity Framework Core you need to create data model for your application. This calls for creating a DbContext class along with one or more entity classes. Luckily, EF Core allows you to reverse engineer the model from an existing database. To that end this article discusses how that can be accomplished.
-
Use XML format with ASP.NET Core web APIs
In one of my past articles I discussed how to deal with XML data in ASP.NET Web APIs. Although JSON is quite popular format in API communication, at times you might need to handle XML data. To that end this article describes the required configuration with a simple example.
-
JWT authentication in ASP.NET Core using HttpClient
In my last two articles (you can read them here and here) we discussed how JWT authentication can be implemented in ASP.NET Core APIs and jQuery client. In this article we will use .NET Core's HttpClient component to perform JWT authentication.
-
JWT Authentication in ASP.NET Core using jQuery Client
In my previous article we discussed what JWT authentication is and how to implement it in ASP.NET Core APIs. In that article you learnt to use Postman tool to test the JWT functionality. In most of the real-world cases you will be handling the JWT using either client side script (jQuery, Angular etc.) or server side code (HttpClient component). To that end this article discusses using jQuery to consume the SecurityController and EmployeeController we developed earlier.
-
Implement JWT Authentication in ASPNET Core APIs
If you developed web applications using ASP.NET before, chances are you are already familiar with cookie authentication. Although cookie based authentication is still available under ASP.NET Core, JSON Web Token or JWT based authentication is becoming more and more common. To that end this article aims at introducing you to JWT and JWT based authentication.
-
Add ASP.NET Core projects to GitHub using Visual Studio 2019
If you a beginner in ASP.NET Core, you might have wondered as to how newly created projects can be placed under a GitHub repository. In this article we will see the overall steps and configuration to do so. You will get an idea about how GitHub can be integrated in Visual Studio 2019.
-
Send emails in ASP.NET Core in 5 easy steps
Sending emails is a common requirement in ASP.NET Core web applications. In this article we will learn how to send emails with attachments using a popular and open source component - MailKit. Let's get going.